From a4a3e675542827bb281a7ceccc7b8f5533eae29f Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Tue, 30 Nov 2021 10:20:39 -0800 Subject: [PATCH] Fix post_install_workaround downgrading development targets (#32633) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: The `__apply_Xcode_12_5_M1_post_install_workaround` script changes the `IPHONEOS_DEPLOYMENT_TARGET` to `11.0` for all pods. This causes problems if the pods were targetting `12.0` or higher. Many expo modules are targetting `12.0`. I fixed this issue by checking the existing version and only bumping the target if it is lower than `11.0`. See also: this discussion post by mikehardy https://github.com/reactwg/react-native-releases/discussions/1#discussioncomment-1619523 ## Changelog [iOS] [Fixed] - __apply_Xcode_12_5_M1_post_install_workaround causing pods targetting iOS 12 and above to fail Pull Request resolved: https://github.com/facebook/react-native/pull/32633 Test Plan: ### Test (failing before this patch, passing after this patch) 1. pick an iOS Pod that has a minimum deployment target of iOS 12 or higher, I chose the Braintree package 2. `npx react-native init myrnapp` 3. Open `ios/Podfile` and add the pod as a dependency: `pod 'Braintree', '~> 5'` (and upgrade the Podfile target to 12 (`platform :ios, '12.0'`)) 4. Compile the app. Before applying this patch: ❌ Build fails because Braintree uses iOS 12 features and was downgraded to target 11.0 After applying this patch: ✅ Build succeeds Reviewed By: fkgozali Differential Revision: D32638171 Pulled By: philIip fbshipit-source-id: 0487647583057f3cfefcf515820855c7d4b16d31 --- scripts/react_native_pods.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index fe68c38607dd6c..7d9c0508ea1888 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -548,13 +548,17 @@ def __apply_Xcode_12_5_M1_post_install_workaround(installer) # The most reliable known workaround is to bump iOS deployment target to match react-native (iOS 11 now). installer.pods_project.targets.each do |target| target.build_configurations.each do |config| - config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0' + # ensure IPHONEOS_DEPLOYMENT_TARGET is at least 11.0 + should_upgrade = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].split('.')[0].to_i < 11 + if should_upgrade + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0' end + end end # But... doing so caused another issue in Flipper: # "Time.h:52:17: error: typedef redefinition with different types" - # We need to make a patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1. + # We need to make a patch to RCT-Folly - remove the `__IPHONE_OS_VERSION_MIN_REQUIRED` check. # See https://github.com/facebook/flipper/issues/834 for more details. - `sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h` + `sed -i -e $'s/ && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)//' Pods/RCT-Folly/folly/portability/Time.h` end