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

App crashes with dyld[38734]: symbol not found in flat namespace '_jump_fcontext' with use_frameworks! #39945

Open
louiszawadzki opened this issue Oct 6, 2023 · 42 comments
Labels
Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Type: Upgrade Issue Issues reported from upgrade issue form

Comments

@louiszawadzki
Copy link
Contributor

New Version

0.73.0-rc.1

Old Version

0.72.5

Build Target(s)

iOS simulator

Output of react-native info

System:
  OS: macOS 13.5.2
  CPU: (10) arm64 Apple M1 Max
  Memory: 23.29 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.1
    path: /var/folders/5l/y80kyhh93kl22_mbytwl_hg40000gq/T/yarn--1696591343127-0.3534219795138642/node
  Yarn:
    version: 1.22.19
    path: /var/folders/5l/y80kyhh93kl22_mbytwl_hg40000gq/T/yarn--1696591343127-0.3534219795138642/yarn
  npm:
    version: 9.5.1
    path: ~/.volta/tools/image/node/18.16.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/louis.zawadzki/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10671973
  Xcode:
    version: 15.0/15A240d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.16.1
    path: /Users/louis.zawadzki/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/louis.zawadzki/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.0-rc.1
    wanted: 0.73.0-rc.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Issue and Reproduction Steps

  • Create a new project with npx react-native@latest init MyApp --version 0.73.0-rc.1
  • Run (cd ios && USE_FRAMEWORKS=dynamic pod install)
  • Build the app using XCode 15

The app crashes immediately with the following error:

dyld[38734]: symbol not found in flat namespace '_jump_fcontext'

XCode screenshot:

image

@louiszawadzki louiszawadzki added Needs: Triage 🔍 Type: Upgrade Issue Issues reported from upgrade issue form labels Oct 6, 2023
@github-actions github-actions bot added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Oct 6, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@cipolleschi
Copy link
Contributor

Hi Luiz, can you try if this is happening also with Xcode 14? I fear that it is an Xcode 15 issue, unfortunately...

@cipolleschi
Copy link
Contributor

Uhm... I just tried and it doesn't repro for me:
Screenshot 2023-10-06 at 13 38 35

@louiszawadzki
Copy link
Contributor Author

Hi,

I get the following different error in XCode 14.3.1 when building the app:
image

Ld /Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/libevent.build/Objects-normal/x86_64/Binary/libevent normal x86_64 (in target 'libevent' from project 'Pods')
    cd /Users/louis.zawadzki/go/src/github.com/DataDog/mobile/apps/MyApp/ios/Pods
    /Applications/Xcode-14.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-ios13.4-simulator -dynamiclib -isysroot /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -L/Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/EagerLinkingTBDs/Release-iphonesimulator -L/Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Products/Release-iphonesimulator/libevent -F/Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/EagerLinkingTBDs/Release-iphonesimulator -F/Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Products/Release-iphonesimulator/libevent -filelist /Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent.LinkFileList -install_name @rpath/libevent.framework/libevent -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Wl -ld_classic -framework Foundation -Xlinker -no_adhoc_codesign -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/libevent.build/Objects-normal/x86_64/libevent_dependency_info.dat -o /Users/louis.zawadzki/Library/Developer/Xcode/DerivedData/MyApp-foosftvymsuqgubztrolvgonqfox/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/libevent.build/Objects-normal/x86_64/Binary/libevent

ld: library not found for -ld_classic
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Following the hint from this issue I'm able to build by removing the -ld_classic flag in Pods and libevent targets (removing it in project.pbxproj wasn't enough), then the app works fine with XCode 14.3.1.

@cipolleschi
Copy link
Contributor

yes, so... to run it in Xcode 14.3, you need to switch the build tool with xcode-select and rerun pod install to let cocoapods remove the flags for you. At that point, you don't have -ld_classic anymore and it work right away.

Can you try again with Xcode 15.1? My app works with Xcode 15.1...

@louiszawadzki
Copy link
Contributor Author

Hi!
Sorry for the long delay, I just retried with rc3 and I don't reproduce the issue anymore, I'll close this issue :)

@mateioprea
Copy link

@cipolleschi i have the exact same problem.
Started a new project npx react-native@latest init AwesomeProjectTest, ran USE_FRAMEWORKS=dynamic NO_FLIPPER=1 pod install

and then i get this
Screenshot 2023-12-12 at 13 53 23

React Native info:

info Fetching system and libraries information...
System:
  OS: macOS 14.2
  CPU: (10) arm64 Apple M1 Max
  Memory: 309.75 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.1
    path: ~/.nvm/versions/node/v18.16.1/bin/node
  Yarn:
    version: 1.22.17
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.nvm/versions/node/v18.16.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/mateioprea/.rvm/gems/ruby-2.7.6/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "33"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 32.0.0
      - 33.0.0
      - 33.0.2
      - 34.0.0
    System Images:
      - android-31 | Google Play ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: Giraffe 2022.3.1 Patch 2 Giraffe 2022.3.1 Patch 2
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 20.0.1
    path: /opt/homebrew/opt/openjdk/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/mateioprea/.rvm/rubies/ruby-2.7.6/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.0
    wanted: 0.73.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false


@aybarska
Copy link

same on "react-native": "0.73.0",

@cipolleschi
Copy link
Contributor

@mateioprea @aybarska

  1. which version of Xcode are you using? (you can check it by running xcodebuild -v)
  2. why are you not using bundler? (specifically, you should run USE_FRAMEWORKS=dynamic NO_FLIPPER=1 bundle exec pod install)
  3. I just tried the following:
npx react-native@latest init AwesomeProjectTest --skip-install
cd AwesomeProjectTest
yarn install
cd ios
bundle install
USE_FRAMEWORKS=dynamic NO_FLIPPER=1 bundle exec pod install
open AwesomeProjectTest.xcworkspace

and them +R

and it works.

$ xcodebuild -version
Xcode 15.1
Build version 15C5028h
Screenshot 2023-12-18 at 15 38 44

Can you try again?

@fontesrp
Copy link

fontesrp commented Dec 19, 2023

@cipolleschi, I tried those steps, and I get the dyld[620]: symbol not found in flat namespace '_jump_fcontext' error only when I run in a physical device. If I target a simulator, everything works fine.

Here's the requested info, if it helps:

$ xcodebuild -version
Xcode 15.1
Build version 15C65

And the output of react-native info:

$ npx react-native@latest info
info Fetching system and libraries information...
System:
  OS: macOS 14.2
  CPU: (10) arm64 Apple M1 Max
  Memory: 2.28 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: ~/.nvm/versions/node/v20.10.0/bin/node
  Yarn:
    version: 1.22.21
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.5
    path: ~/.nvm/versions/node/v20.10.0/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/rfontes/.rvm/gems/ruby-3.0.6/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.21
    path: /usr/bin/javac
  Ruby:
    version: 3.0.6
    path: /Users/rfontes/.rvm/rubies/ruby-3.0.6/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.1
    wanted: 0.73.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

@cipolleschi
Copy link
Contributor

I managed to reproduce it.
This is not a simple bug, as the stack trace reports that it happens in thread 1 at startup with little to no extra information.
I also tried in release mode and it still fails.
I'll need some more time to investigate. It could be an apple bug of the new linker too.

Have you tried with Xcode 15.2-beta already?

@cipolleschi cipolleschi reopened this Dec 27, 2023
@cipolleschi
Copy link
Contributor

cipolleschi commented Dec 27, 2023

So, I made another test.
The app runs properly with USE_FRAMEWORKS=static. For the time being, this should be a valid workaround.

Meanwhile, I found that jump_fcontext is a function in boost. So, what I think is happening is that boost is not compiled to a framework and not copied over to the device.

@piraces
Copy link

piraces commented Dec 28, 2023

Hi there @cipolleschi , I keep getting the error mentioned in the issue when running on a physical device (using the USE_FRAMEWORKS=static workaround).

Using Xcode 15.1:

$ xcodebuild -version
Xcode 15.1
Build version 15C65

The output of react-native info:

$ npx react-native@latest info
info Fetching system and libraries information...
System:
  OS: macOS 14.2.1
  CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
  Memory: 1.55 GB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: /usr/local/bin/node
  Yarn:
    version: 1.22.21
    path: /usr/local/bin/yarn
  npm:
    version: 9.8.1
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 34.0.0
    System Images:
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.1
    wanted: 0.73.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Any ideas on how to get on this? Thank you!

EDIT: managed to build & run successfully by removing -ld_classic from the Pods project:
Pods project

@cipolleschi
Copy link
Contributor

which version of Xcode are you using? That flag has been added by Apple because we actually asked them to give us a way to make C++'s weak symbols work with their new linker.
I know that they fixed the issue for good in Xcode 15.1, so we might be able to remove it for everyone right now!

@piraces
Copy link

piraces commented Dec 29, 2023

I'm actually using Xcode 15.1 (Build version 15C65). Maybe it's the case and we can remove that flag?

@cipolleschi
Copy link
Contributor

@piraces yes, I'll work on that this week or next week, worst case scenario.
There are a few test that I want to run, to make sure we don't break React Native for other users, but I'm planning that work! Many thanks for reporting this.

@delphinebugner
Copy link
Contributor

Hi! For the record, I had the same issue as mention above:

  • on XCode 15.0
  • with RN 0.73.1
  • using Dynamic Frameworks
  • building on physical device only
  • simulators okay (note: I build only using Rosetta for simulators because of one of my dependancies)

Switching to Static Frameworks was enough 🙂

I'm available to give more info / to test other workaround, ideally I would like to go back to dynamics later!

@cipolleschi
Copy link
Contributor

Thanks for the reporting.
Next week I'll be back in the office, with a better connection and bandwidth, and I'll be able to download multiple Xcode and test with/without the flags on multiple system to implement a solution that might work for everyone.

My understanding, as of today is that:

  • If you use Xcode < 15 => You don't need flags, but you can't target iOS 17
  • if you use Xcode >= 15.0.0 && < 15.1.0 => You need the flags, you can target iOS 17
  • if you use Xcode >= 15.1 => You don't need flags, you can target iOS 17

I want to test these hypothesis, but my current connectivity foes not allow me to download 30+ Gb in a day 🤦

@khalidahmada
Copy link

@mateioprea It works on simulator but not on real device

@khalidahmada
Copy link

@cipolleschi, I've attempted to target iOS 17 using Xcode 15.1, but I'm encountering the same issue on a real device:

dyld[1495]: symbol not found in flat namespace '_jump_fcontext'

@cipolleschi
Copy link
Contributor

Hi everyone.
I've spent a couple of days investigating the issue. I think we should be able to fix the problem by adding this patch to the utils.rb file:

  • line 165
              project.build_configurations.each do |config|
                # fix for weak linking
                self.safe_init(config, other_ld_flags_key)
-              if self.is_using_xcode15_or_greater(:xcodebuild_manager => xcodebuild_manager)
+             if self.is_using_xcode15_0(:xcodebuild_manager => xcodebuild_manager)
  • line 389
-  def self.is_using_xcode15_or_greater(xcodebuild_manager: Xcodebuild)
+  def self.is_using_xcode15_0(xcodebuild_manager: Xcodebuild)
        xcodebuild_version = xcodebuild_manager.version

        # The output of xcodebuild -version is something like
        # Xcode 15.0
        # or
        # Xcode 14.3.1
        # We want to capture the version digits
        regex = /(\d+)\.(\d+)(?:\.(\d+))?/
        if match_data = xcodebuild_version.match(regex)
            major = match_data[1].to_i
+         minor = match_data[2].to_i     
-          return major >= 15
+          return major == 15 && minor == 0
        end

        return false
    end

With these changes, I was able to run a 0.73 app on the device.

However, the reason why we have to add the -ld_classic flag with Xcode 15 was because Apple reimplemented the linker in Xcode 15 and it was not compatible with versions of iOS < 15.

Now, I cannot install iOS 14.5 on my laptop anymore, because it is not compatible with Sonoma.
The last version of macOS that can install and build iOS < 15 is macOS 13.5 IIRC (which is Ventura).

Is there someone that can help out by:

  1. Create a new app with 0.73
  2. Modify the node_modules/react-native/scripts/cocoapods/utils.rb file applying the patches above
  3. Run the app on a simulator/device using iOS < 15 (e.g. 14.5)
  4. Report its finding
    🙏🙏🙏🙏

The help would be much appreciated and will help the whole community!

cipolleschi added a commit to cipolleschi/react-native that referenced this issue Jan 10, 2024
Summary:
While developing Xcode 15, Apple reimplemented the linker.
In Xcode 15.0, the linker was making old iOS (< 15) crash when they were built using Xcode 15.

To fix that, we make Apple create new compiler flags (`-ld_classic`) to have a backward compatible linker.

In Xcode 15.1, Apple fixed that behavior, so the flags should not be required anymore.
But now, if we pass `-ld_classic` to the linker and we have an app that is using `use_framworks!`, that app crashes at startup.

This change remove the flags if the Xcode that is used is 15.1 or greater.

*Note:* The previous change added the flags to Hermes as well. I tested this fix in a configuration where Hermes has the flags and React Native does not, and it works. So we are removing the flags only from React Native.

This Fixes facebook#39945

## Changelog:
[Internal] - Do not add the `-ld_classic` flag if the app is built with Xcode 15.1 or greater.

Differential Revision: D52658197
@cipolleschi
Copy link
Contributor

So, I was able to test using Firebase Test Lab and it looks like that older devices are working.

I created PRs also for the supported versions:

cipolleschi added a commit to cipolleschi/react-native that referenced this issue Jan 11, 2024
)

Summary:

While developing Xcode 15, Apple reimplemented the linker.
In Xcode 15.0, the linker was making old iOS (< 15) crash when they were built using Xcode 15.

To fix that, we make Apple create new compiler flags (`-ld_classic`) to have a backward compatible linker.

In Xcode 15.1, Apple fixed that behavior, so the flags should not be required anymore.
But now, if we pass `-ld_classic` to the linker and we have an app that is using `use_framworks!`, that app crashes at startup.

This change remove the flags if the Xcode that is used is 15.1 or greater.

*Note:* The previous change added the flags to Hermes as well. I tested this fix in a configuration where Hermes has the flags and React Native does not, and it works. So we are removing the flags only from React Native.

This Fixes facebook#39945

## Changelog:
[Internal] - Do not add the `-ld_classic` flag if the app is built with Xcode 15.1 or greater.

Reviewed By: cortinico

Differential Revision: D52658197
cipolleschi added a commit to cipolleschi/react-native that referenced this issue Jan 11, 2024
)

Summary:

While developing Xcode 15, Apple reimplemented the linker.
In Xcode 15.0, the linker was making old iOS (< 15) crash when they were built using Xcode 15.

To fix that, we make Apple create new compiler flags (`-ld_classic`) to have a backward compatible linker.

In Xcode 15.1, Apple fixed that behavior, so the flags should not be required anymore.
But now, if we pass `-ld_classic` to the linker and we have an app that is using `use_framworks!`, that app crashes at startup.

This change remove the flags if the Xcode that is used is 15.1 or greater.

*Note:* The previous change added the flags to Hermes as well. I tested this fix in a configuration where Hermes has the flags and React Native does not, and it works. So we are removing the flags only from React Native.

This Fixes facebook#39945

## Changelog:
[Internal] - Do not add the `-ld_classic` flag if the app is built with Xcode 15.1 or greater.

Reviewed By: cortinico

Differential Revision: D52658197
cipolleschi added a commit to cipolleschi/react-native that referenced this issue Jan 11, 2024
)

Summary:

While developing Xcode 15, Apple reimplemented the linker.
In Xcode 15.0, the linker was making old iOS (< 15) crash when they were built using Xcode 15.

To fix that, we make Apple create new compiler flags (`-ld_classic`) to have a backward compatible linker.

In Xcode 15.1, Apple fixed that behavior, so the flags should not be required anymore.
But now, if we pass `-ld_classic` to the linker and we have an app that is using `use_framworks!`, that app crashes at startup.

This change remove the flags if the Xcode that is used is 15.1 or greater.

*Note:* The previous change added the flags to Hermes as well. I tested this fix in a configuration where Hermes has the flags and React Native does not, and it works. So we are removing the flags only from React Native.

This Fixes facebook#39945

## Changelog:
[Internal] - Do not add the `-ld_classic` flag if the app is built with Xcode 15.1 or greater.

Reviewed By: cortinico

Differential Revision: D52658197
gokul1099 pushed a commit to gokul1099/react-native-visionos that referenced this issue Jan 17, 2024
)

Summary:
Pull Request resolved: facebook#42230

While developing Xcode 15, Apple reimplemented the linker.
In Xcode 15.0, the linker was making old iOS (< 15) crash when they were built using Xcode 15.

To fix that, we make Apple create new compiler flags (`-ld_classic`) to have a backward compatible linker.

In Xcode 15.1, Apple fixed that behavior, so the flags should not be required anymore.
But now, if we pass `-ld_classic` to the linker and we have an app that is using `use_framworks!`, that app crashes at startup.

This change remove the flags if the Xcode that is used is 15.1 or greater.

*Note:* The previous change added the flags to Hermes as well. I tested this fix in a configuration where Hermes has the flags and React Native does not, and it works. So we are removing the flags only from React Native.

This Fixes facebook#39945

## Changelog:
[Internal] - Do not add the `-ld_classic` flag if the app is built with Xcode 15.1 or greater.

Reviewed By: cortinico

Differential Revision: D52658197

fbshipit-source-id: 37d6bc895921c0fc3661f301870477191e7e42b3
@wkwyatt
Copy link

wkwyatt commented Mar 25, 2024

Hey @cipolleschi, I hate that this is coming back up but I am having this problem with

  • RN 0.73.3
  • Xcode 15.2
Xcode 15.2
Build version 15C500b

And system

System:
  OS: macOS 14.3
  CPU: (10) arm64 Apple M1 Max
  Memory: 2.92 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.15.0
    path: ~/.nvm/versions/node/v18.15.0/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.6.2
    path: ~/.nvm/versions/node/v18.15.0/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/wwyatt/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
IDEs:
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.7.7
    path: /Users/wwyatt/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.3
    wanted: 0.73.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: true
  newArchEnabled: true

Our app is rather large and has a mix of dynamic and static frameworks.
Our min version of iOS is also 16
And when building the app, it crashes with the error
symbol not found in flat namespace '_jump_fcontext'

I also tried manually removing all the -ld_classic flags and it still didn't work. Any suggestions?

@sunzongzheng
Copy link

sunzongzheng commented Mar 28, 2024

same problem here with Xcode@15.3 and react-native 0.73.6 just

npx react-native@latest init AwesomeProjectTest
USE_FRAMEWORKS=dynamic NO_FLIPPER=1 pod install

System:
OS: macOS 14.4.1
CPU: (12) arm64 Apple M2 Pro
Memory: 599.81 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.19.0
path: /usr/local/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 10.2.3
path: /usr/local/bin/npm
Watchman:
version: 2024.03.18.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.14.3
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.4
- iOS 17.4
- macOS 14.4
- tvOS 17.4
- visionOS 1.1
- watchOS 10.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.11005911
Xcode:
version: 15.3/15E204a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.8
path: /usr/bin/javac
Ruby:
version: 3.3.0
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.6
wanted: 0.73.6
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false

@bruno-centanaro
Copy link

Same for me, were you able to find a fix?

1 similar comment
@TomWq
Copy link

TomWq commented Apr 3, 2024

Same for me, were you able to find a fix?

@cipolleschi
Copy link
Contributor

Hi everyone, I was on a long PTO (3 weeks) and came back this week.
I'm looking into this.

@cipolleschi cipolleschi reopened this Apr 3, 2024
@cipolleschi
Copy link
Contributor

@sunzongzheng @wkwyatt I just tried the following steps:

npx react-native@latest init AwesomeProjectTest --version latest --skip-install
cd AwesomeProjectTest  
yarn install   
cd ios
bundle install
USE_FRAMEWORKS=dynamic NO_FLIPPER=1 bundle exec pod install  
 open AwesomeProjectTest.xcworkspace 

Build: +B
And it built successfully.

I'm using React Native 0.73.6 and Xcode 15.3.

I think that there is something funky in your local setups, perhaps caching.

Could you try to:

  1. pod deintegrate
  2. Delete derived data in Xcode
  3. USE_FRAMEWORKS=dynamic NO_FLIPPER=1 bundle exec pod install
    and try again?

@bruno-centanaro
Copy link

Are you running it on a device later? Because my issue is not compiling/building but if I run it on a physical device

@cipolleschi
Copy link
Contributor

No I was only building. I'll try to connect a device, then.

@cipolleschi
Copy link
Contributor

I'm very sad.
Xcode 15.2 => everytyhing works.
Xcode 15.3 => crashes with the above error.

This is an Xcode regression.
I'll try to:

  1. apply the old -Wl -ld_classic flags and see if it fixes.
  2. try to reach out to Apple to talk about this.

@cipolleschi
Copy link
Contributor

Some good and bad news here.

The good news are that:

  1. 0.73 is broken only with Dynamic Frameworks. Static Frameworks and Static Libraries works properly. Previous versions of React Native were not supporting Dynamic Frameworks, so they should not be affected.
  2. 0.74 is not affected, it works properly even with Dynamic Frameworks.

The reason why 0.74 is not affected even with Dynamic Frameworks is the following:

  1. The root cause for the failure is that Folly/Futures can't find the symbol _jump_fcontext.
  2. The symbol _jump_fcontext is provided by boost, but boost is linked as an empty target in React Native, so, when it compiled to a Dynamic Frameworks, there is no code that the dynamic linker can search for the symbol.
  3. 0.74 removed the dependency from Folly/Future, so we are not looking for the symbol anymore.

The bad news is that, even by re-enabling the -ld_classic flag, 0.73 with Dynamic Frameworks is still broken.

@bruno-centanaro @sunzongzheng how critical is the dynamic framework setup for you? Would your app work also with the static framework setup?

@bruno-centanaro
Copy link

Thanks for the update. Dynamic frameworks is a must for my app but installing xcode 15.1 does the job so I guess I'll need to instruct my team to change it manually. Thanks again

@cipolleschi
Copy link
Contributor

I'm really sorry for this as I hoped we fixed this for good. :(
I'm discussing internally how to move forward, perhaps we can find a fix and backport it to 0.73 as well, but it will take some time...

@artkow
Copy link

artkow commented Apr 5, 2024

I just disabled Hermes on iOS in Podfile and it helped.
:hermes_enabled => false,

@cipolleschi
Copy link
Contributor

yeah, that's another workaround. The problem is that React-Hermes depends on a subpod of Folly which depends on the _jump_fcontext symbol provided by boost.
The symbol is a weak symbol and the new Apple linker does not supports weak symbols anymore. :(

@delphinebugner
Copy link
Contributor

Dynamic frameworks are not critical in my app, so let's get back to the good old static 🐢 🐢

Thanks for looking into this! Got really confused to have the crash back when upgrading to XCode 15.3 🥲

@KingAmo
Copy link

KingAmo commented May 22, 2024

same here, any update on this?

  • use_frameworks!
  • hermes enabled
  • new arc: false
  • react-native:0.73.8

Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild

SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5

CocoaPods:
version: 1.15.2
path: /opt/homebrew/bin/pod

@KingAmo
Copy link

KingAmo commented May 23, 2024

same here, any update on this?

  • use_frameworks!
  • hermes enabled
  • new arc: false
  • react-native:0.73.8

Xcode: version: 15.4/15F31d path: /usr/bin/xcodebuild

SDKs: iOS SDK: Platforms: - DriverKit 23.5 - iOS 17.5 - macOS 14.5 - tvOS 17.5 - visionOS 1.2 - watchOS 10.5

CocoaPods: version: 1.15.2 path: /opt/homebrew/bin/pod

update: after downgrade Xcode to 15.2, this error gone (Xcode 15.3 not work either)

@cipolleschi
Copy link
Contributor

Has anyone tried with Xcode 15.4 already? (haven't had the time yet!)

@KingAmo
Copy link

KingAmo commented Jun 5, 2024

Has anyone tried with Xcode 15.4 already? (haven't had the time yet!)

yes , see my commont above, i already tried Xcode 15.4

@vitas61
Copy link

vitas61 commented Sep 4, 2024

Problem was solved on 0.74.x

  • use_frameworks! (Dynamic)
  • hermes: enabled
  • new arc: false
  • react-native: 0.74.5
  • xcode: 15.4 (15F31d)

now everything works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Triage 🔍 Type: Upgrade Issue Issues reported from upgrade issue form
Projects
None yet
Development

Successfully merging a pull request may close this issue.