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

[RN][iOS] Fix symbol not found _jump_fcontext with use_frameworks! #42229

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

cipolleschi
Copy link
Contributor

@cipolleschi cipolleschi commented 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.

Changelog:

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

Test Plan:

Tested locally that a new app with use_frameworks! is not crashing.
Tested on Firebase Testlab that a new app built with Xcode 15.2 and running on iOS <15 is not crashing at startup.

@cipolleschi cipolleschi changed the base branch from main to 0.71-stable January 10, 2024 13:26
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jan 10, 2024
@cipolleschi cipolleschi marked this pull request as ready for review January 10, 2024 13:27
@floydkim
Copy link

floydkim commented Jan 12, 2024

Thank you for resolving the issue. 😄 👍
And also, the explanation of -ld_classic was very informative for me.

I created a patch-package diff with the changes in the PR. (react-native 0.71.15)

react-native+0.71.15.patch

diff --git a/node_modules/react-native/scripts/cocoapods/utils.rb b/node_modules/react-native/scripts/cocoapods/utils.rb
index 154ba3e..25968c2 100644
--- a/node_modules/react-native/scripts/cocoapods/utils.rb
+++ b/node_modules/react-native/scripts/cocoapods/utils.rb
@@ -160,7 +160,7 @@ class ReactNativePodsUtils

                 # fix for weak linking
                 self.safe_init(config, other_ld_flags_key)
-                if self.is_using_xcode15_or_greter(:xcodebuild_manager => xcodebuild_manager)
+                if self.is_using_xcode15_0(:xcodebuild_manager => xcodebuild_manager)
                     self.add_value_to_setting_if_missing(config, other_ld_flags_key, xcode15_compatibility_flags)
                 else
                     self.remove_value_from_setting_if_present(config, other_ld_flags_key, xcode15_compatibility_flags)
@@ -299,7 +299,7 @@ class ReactNativePodsUtils
         end
     end

-    def self.is_using_xcode15_or_greter(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
@@ -310,7 +310,8 @@ class ReactNativePodsUtils
         regex = /(\d+)\.(\d+)(?:\.(\d+))?/
         if match_data = xcodebuild_version.match(regex)
             major = match_data[1].to_i
-            return major >= 15
+            minor = match_data[2].to_i
+            return major == 15 && minor == 0
         end

         return false

When I ran the pod install on a machine with Xcode 15.2,
I see a minor blemish and want to inform you.

it produces " " value to OTHER_LDFLAGS. (all configurations)

it looks wierd but build is OK.

@hurali97 hurali97 merged commit bb592ef into 0.71-stable Jan 15, 2024
51 of 55 checks passed
@cortinico cortinico deleted the cipolleschi/fix-_jump_fcontex-071 branch June 10, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner Pick Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants