Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building iOS to a real device fails #10

Closed
raghav-mylagary opened this issue Jun 29, 2022 · 17 comments
Closed

Building iOS to a real device fails #10

raghav-mylagary opened this issue Jun 29, 2022 · 17 comments

Comments

@raghav-mylagary
Copy link

raghav-mylagary commented Jun 29, 2022

When building the rnfbdemo project to real iOS device it fails with the below error

Link folly
ld: -U and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@raghav-mylagary
Copy link
Author

@mikehardy
Copy link
Owner

mikehardy commented Jun 29, 2022

Oh no! @raghavyadavm can you test that patch on any other project to see how it affects thing? If that patch is bad that means we have a generic problem with the upcoming react-native 0.69.1 as that patch will be included in the main release. This could be a big deal

@raghav-mylagary
Copy link
Author

raghav-mylagary commented Jun 29, 2022

@mikehardy I created a new project using 69.1 and got the same error on a real device

1. npx react-native init RN --version=0.69.1
2. Enabled Hermes and use_frameworks in podfile
3. Build on a real iOS device

Error
image

@mikehardy
Copy link
Owner

Thanks again for bringing this up - I tagged you in the related react-native discussions for well-earned credit, of course unsubscribe if it's bothersome (and, apologies) - I dropped that part of the patch and make sure hermes is not enabled in make-demo.sh now, so it works with react-native 0.69.0 - I'll have to reverse that part of the patch as a forward-port to react-native 0.69.1, I'll do that in a bit

@mikehardy
Copy link
Owner

Turns out (from the related PR on react-native) that this may always be incompatible with bitcode but apparently bitcode is deprecated in Xcode 14 anyway. So, it is perhaps best to simply disable it, then there's no problem. In Podfile in postinstall this will do it, I will probably update make-demo.sh to do this when I get a chance

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end

@raghav-mylagary
Copy link
Author

Great thanks for the workaround. I will update my project with these settings

@raghav-mylagary
Copy link
Author

Disabling Bitcode started giving me errors with other libraries like Reanimated. I ended up using framework with the option use_frameworks! :linkage => :static and it solved the problem

@mikehardy
Copy link
Owner

Yes - other libraries may have issues as well, it really is a big change, thanks for reporting what worked, that will help me and others going forward!

@raghav-mylagary
Copy link
Author

I create a PR to update the demo.sh with the above changes #11

@raghav-mylagary
Copy link
Author

Unfortunately, the release builds are failing with these errors. I had to disable the Hermes for use_frameworks to work
image

@ptreitler
Copy link

Turns out (from the related PR on react-native) that this may always be incompatible with bitcode but apparently bitcode is deprecated in Xcode 14 anyway. So, it is perhaps best to simply disable it, then there's no problem. In Podfile in postinstall this will do it, I will probably update make-demo.sh to do this when I get a chance

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end

This workaround solved the issue for me, but I also had to disable Bitcode for release builds in my project's XCode config.

@mikehardy
Copy link
Owner

@ptreitler

but I also had to disable Bitcode for release builds in my project's XCode config

Hmm - perhaps instead of target.build_configurations.each it needs to be broader, more like this one?

sed -i -e $'s/react_native_post_install(installer)/react_native_post_install(installer)\\\n \\\n installer.aggregate_targets.each do |aggregate_target|\\\n aggregate_target.user_project.native_targets.each do |target|\\\n target.build_configurations.each do |config|\\\n config.build_settings[\'ONLY_ACTIVE_ARCH\'] = \'YES\'\\\n config.build_settings[\'EXCLUDED_ARCHS\'] = \'i386\'\\\n end\\\n end\\\n aggregate_target.user_project.save\\\n end/' ios/Podfile

@raghavyadavm text of error messages vs images are strongly preferred if possible, I'm traveling and mobile right now most of the time so images are rough on me to see all pinch+zoom :-) - it might be best to post that in the react-native main repo as it looks like you've stumbled on "the next thing..." after getting the basic build+link to work. Hopefully it's an easy fix - you might try pinging @Kudo as he was the creator of the original fix that made Hermes build at all (the first, important step) and the error may be familiar to them, or...it could be aware from areas any of us are familiar with 😅

@Kudo
Copy link

Kudo commented Jul 18, 2022

hi there!

sorry being late for this response. i finally get a chance to investigate this problem and it turns out to me that use_frameworks! + hermes is not supported from day one.

the root cause is that due to React-Core podspec does not have a dependency to React-hermes, so here the import is not available. and the runtime is jsc but not hermes.

i need some time to think a proper solution for the issue. just to update my investigation here.

@mikehardy
Copy link
Owner

I always appreciate your investigations and efforts @Kudo - thanks for even trying, sincerely. I posted something related here on the road to 0.70 discussion - reactwg/react-native-releases#26 (reply in thread)

I've exposed the issue in this script (at least) by adding exposure of the __jsiExecutorDescription variable on this branch where I am playing with things:

@Kudo
Copy link

Kudo commented Jul 19, 2022

nice finding for it's jsc not hermes by the __jsiExecutorDescription. i proposed a pr in facebook/react-native#34222 let's see how do people think for this approach.

@maxmandia
Copy link

Turns out (from the related PR on react-native) that this may always be incompatible with bitcode but apparently bitcode is deprecated in Xcode 14 anyway. So, it is perhaps best to simply disable it, then there's no problem. In Podfile in postinstall this will do it, I will probably update make-demo.sh to do this when I get a chance

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end

This workaround solved the issue for me, but I also had to disable Bitcode for release builds in my project's XCode config.

This worked for me too :)

@karladler
Copy link

karladler commented Aug 7, 2022

I tried all of the solutions mentioned above, but still no luck.
My Version is RN 69.3

Edit: upgraded all other js modules and did "pod install" afterwards. Works now. I guess running "pod install" is a necessary step, so should be mentioned maybe in the resolution. Thanks.

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

No branches or pull requests

6 participants