Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Flipper enabled by default on release builds #4627

Open
abejfehr opened this issue Mar 23, 2023 · 20 comments
Open

Flipper enabled by default on release builds #4627

abejfehr opened this issue Mar 23, 2023 · 20 comments

Comments

@abejfehr
Copy link

🐛 Bug Report

FB_SONARKIT_ENABLED is currently set to 1 on builds other than ones where Flipper should be enabled.

The Flipper documentation says you should be able to:

Call FlipperConfiguration.enabled with a specific version in ios/Podfile, for example: :flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.159.0' }),.

To Reproduce

Initialize a new react native app:

npx [email protected] init rntest

Modify the Podfile so the flipper_configuration is:

flipper_config = FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.182.0' })

Open the workspace in XCode and observe that FB_SONARKIT_ENABLED is still set:

image

Environment

Flipper 0.182.0

@abejfehr
Copy link
Author

Maybe this is a red herring, because on a working project the FlipperKit config also has FB_SONARKIT_ENABLED=1 for each of them 🤔

There really has to be a better solution to this issue though: #4471

@robertbarclay
Copy link
Contributor

robertbarclay commented Apr 1, 2023

Try

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'FlipperKit'
      pod_release_xcconfig_filename = File.join(installer.config.project_pods_root, "Target\ Support\ Files/#{target.name}/#{target.name}.release.xcconfig")
      if File.exist?(pod_release_xcconfig_filename)
        pod_release_xcconfig_content = File.read(pod_release_xcconfig_filename)
        pod_release_xcconfig_content = pod_release_xcconfig_content.gsub(/-Xcc -DFB_SONARKIT_ENABLED=1/, "-Xcc")
        pod_release_xcconfig_content = pod_release_xcconfig_content.gsub(/FB_SONARKIT_ENABLED=1/, "")
        File.open(pod_release_xcconfig_filename, "w") { |file| file << pod_release_xcconfig_content }
      end
    end
  end
end

This seems to do the trick for me, and i am able to archive with no header issues, and inspecting the pod build configurations, all looks to be in order once this is applied. Was using version 0.185.0.

@muhsin-k
Copy link

muhsin-k commented Apr 4, 2023

@abejfehr Did you able to fix the issue?

@abejfehr
Copy link
Author

abejfehr commented Apr 6, 2023

@muhsin-k I didn't see your response, sorry 😅

I'm currently using a patch-package that removes checks for FB_SONARKIT_ENABLED in the react-native-flipper dep, but I'll give this solution a shot

@chmac
Copy link

chmac commented Apr 18, 2023

@abejfehr Would you be open to sharing the patch somewhere? I'm hitting this issue and a patch package patch file would be very handy right about now! :-)

@nicolastrafenchuk
Copy link

nicolastrafenchuk commented Apr 18, 2023

With Flipper 0.189.0 I don't have FB_SONARKIT_ENABLED set for release.

image

I have fixed the error 'Undefined symbol: OBJC_CLASS$_FlipperClient ...' by adding 'Release' to FlipperConfiguration:

:flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => 0.189.0 })

Hope that helps

@chmac
Copy link

chmac commented Apr 20, 2023

For anyone else who finds this issue and like me doesn't understand where these code snippets folks are posting are supposed to go, here's what I believe to be the answer:

  • The lines that start :flipper_configuration belong in the ios/Podfile file
    • There should be an existing :flipper_configuration => flipper_config line in there

I think the same is true of the block above from @robertbarclay like post_install do |installer|.

@nicolastrafenchuk I believe in your example above, I can just change my app.json file to the same effect like so:

    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "flipper": "0.189.0"
          }
        }
      ]
    ]

That results in the same value being set in my Podfile, at least, I'm pretty sure it does.

My solution

However, none of the above worked for me. What did fix the issue for me was a suggestion I found here and here.

I had to add arm64 to the list of excluded architectures. I did that by opening the project in XCode, choosing the "appname.xcodeproj" option from the navigator on the left, then opening the "Build Settings" tab. The first section "Architectures" has an option "Excluded Architectures" and under the "Release" heading I double clicked the value (mine already said i386 then clicked a + to add a second entry arm64. Finally, it looks like this:

Screenshot 2023-04-20 at 19 06 10

Now I can build for Release and run it on a simulator. I will admit I learned a bunch about pod files and iOS in general during the process!

Thanks @nicolastrafenchuk and the others for sharing tips, they were all helpful on the path to eventual success!

@nicolabortignon
Copy link

still having this problem. tried all the of the above
@abejfehr would you mind share your patch-packet?

@andreygamb
Copy link

+1

1 similar comment
@elkinjosetm
Copy link

+1

@Shaninnik
Copy link

Noticed the same issue. It has started with me getting 'Undefined symbol: OBJC_CLASS$_FlipperClient ...' error when trying to archive, I am not even sure what caused it because I have not done any changes that could lead to it. Fixed it with applying same thing that @nicolastrafenchuk did. But I still had FB_SONARKIT_ENABLED in Release configuration no matter what. It did not make me comfortable so I applied @robertbarclay fix to pod file.

Very weird, not sure what is going on.

@ishan-sharma-me
Copy link

Flipper 0.189.0 has fixed this

@Shaninnik
Copy link

It does not, there is still FB_SONARKIT_ENABLED=1 for all configuration, tested with 0.189.0 and 0.203.0 unless you apply fixes from above. I am NOT using expo.

@westanvv
Copy link

This solution should work #4278 (comment)

@Danushka50
Copy link

With Flipper 0.189.0 I don't have FB_SONARKIT_ENABLED set for release.

image

I have fixed the error 'Undefined symbol: OBJC_CLASS$_FlipperClient ...' by adding 'Release' to FlipperConfiguration:

:flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => 0.189.0 })

Hope that helps

It Works. Thanks.

@vok123
Copy link

vok123 commented Jul 28, 2023

#4278 (comment)

Good job. It's work for me .

    1. :flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => '0.189.0' })
    1. pod install

@forbesgillikin
Copy link

With Flipper 0.189.0 I don't have FB_SONARKIT_ENABLED set for release.

image

I have fixed the error 'Undefined symbol: OBJC_CLASS$_FlipperClient ...' by adding 'Release' to FlipperConfiguration:

:flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => 0.189.0 })

Hope that helps

This isn't necessarily a resolution to this issue. By adding "Release" to your config, you are enabling Flipper for your Release which is unnecessary and not recommended.

@Navipro70
Copy link

FB_SONARKIT_ENABLED is still enabled in release and debug modes. In AppDelegate.mm some modules depends on it, that means we let them to be included in Release (for example React native perfomance monitor). I think we should replace FB_SONARKIT_ENABLED with another indicator or fix FB_SONARKIT_ENABLED for Release mode

@MoamberRaza
Copy link

:flipper_configuration => flipper_config = FlipperConfiguration.enabled(["Release","Debug"], { 'Flipper' => '0.191.1' }),

adding this line will remove _UNDEFINED_SYMBOL errors

by the way anyone help in it where to change it from its own config. or how can we upgrade it.

@cooper
Copy link

cooper commented Jan 9, 2024

Has anyone come up with a workaround which does not involve enabling Flipper on release builds undesirably?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests