Skip to content

Commit ac4ddec

Browse files
fkgozalifacebook-github-bot
authored andcommitted
OSS: add Xcode 12.5 + M1 machines CocoaPods post_install workaround
Summary: Context: there are multiple issues currently exposed by Xcode 12.5 and/or M1 machine + Flipper. To unblock the new 0.66 release, let's add this workaround in the official react_native_pods.rb recipe and make RNTester and new app Podfile's call it directly. Changelog: [iOS][Fixed] Added workaround for Xcode 12.5 / M1 machines build issues Reviewed By: lunaleaps Differential Revision: D30691291 fbshipit-source-id: 8b24cc60da3d620dbc90f95c77f2345e18c28212
1 parent 945c5f7 commit ac4ddec

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

packages/rn-tester/Podfile

+1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,5 @@ end
6161

6262
post_install do |installer|
6363
react_native_post_install(installer)
64+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
6465
end

scripts/react_native_pods.rb

+35
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,38 @@ def use_react_native_codegen!(spec, options={})
212212
:show_env_vars_in_log => true
213213
}
214214
end
215+
216+
# This provides a post_install workaround for build issues related Xcode 12.5 and Apple Silicon (M1) machines.
217+
# Call this in the app's main Podfile's post_install hook.
218+
# See https://github.com/facebook/react-native/issues/31480#issuecomment-902912841 for more context.
219+
# Actual fix was authored by https://github.com/mikehardy.
220+
# New app template will call this for now until the underlying issue is resolved.
221+
def __apply_Xcode_12_5_M1_post_install_workaround(installer)
222+
# Apple Silicon builds require a library path tweak for Swift library discovery to resolve Swift-related "symbol not found".
223+
# Note: this was fixed via https://github.com/facebook/react-native/commit/eb938863063f5535735af2be4e706f70647e5b90
224+
# Keeping this logic here but commented out for future reference.
225+
#
226+
# installer.aggregate_targets.each do |aggregate_target|
227+
# aggregate_target.user_project.native_targets.each do |target|
228+
# target.build_configurations.each do |config|
229+
# config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
230+
# end
231+
# end
232+
# aggregate_target.user_project.save
233+
# end
234+
235+
# Flipper podspecs are still targeting an older iOS deployment target, and may cause an error like:
236+
# "error: thread-local storage is not supported for the current target"
237+
# The most reliable known workaround is to bump iOS deployment target to match react-native (iOS 11 now).
238+
installer.pods_project.targets.each do |target|
239+
target.build_configurations.each do |config|
240+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
241+
end
242+
end
243+
244+
# But... doing so caused another issue in Flipper:
245+
# "Time.h:52:17: error: typedef redefinition with different types"
246+
# We need to make a patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1.
247+
# See https://github.com/facebook/flipper/issues/834 for more details.
248+
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
249+
end

template/ios/Podfile

+1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ target 'HelloWorld' do
2525

2626
post_install do |installer|
2727
react_native_post_install(installer)
28+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
2829
end
2930
end

0 commit comments

Comments
 (0)