Xcode 12 Compilation Errors (While running with iOS 14 Simulators)
Building a large project on Xcode Version 12.0.1 (12A7300) with a simulator selected (iOS 14), gives various errors, whether the same project was perfectly working with Xcode 11.x and lower versions.
Note: Tested Project is a large project which is having many popular third-party cocoa pods [Swift + ObjC] AFNetworking, Firebase, RN Modules, Notification Extension target, etc.
Some of the Errors are as below:
- No such modules (import installed pods)
- Cocoapods post-build step with the script they install issue -> Pods/Target Support Files/Pods-All-Apps-XXX/Pods-All-Apps-XXX-frameworks.sh: line 141: ARCHS[@]: unbound variable
- ‘ObjCheaderFile.h’ file not found. (ObjC Headers in bridging file)
Suddenly these errors Why?
Now to understand this, I would like you to highlight 1 important update from Xcode 12 Release Notes:
Below are 2 Main reasons for raised erros due to this change:
arm64architecture support & and Xcode 12 Compatible version have not been provided by many popular third party libraries yet (Like Firebase, AFNetworking, etc).
Xcode 11 used to automatically translate building for arm64 for the simulator into building for x86_64, but now that arm64 is a valid simulator architecture (it’s the Apple Silicon architecture), that translation no longer occurs.So now whenever you try to build this test project under selected iOS 14 simulator, it will return you with the mentioned errors as the link target type will be an unknown type ‘arm64-apple-ios11.0-simulator’ which cause the build failed.
2. Because the Valid Architectures build setting being removed in Xcode 12, So Project file open in Xcode 12 will auto-generate a VALID_ARCHS macro in User-Defines, and this macro will make the build failed.
Steps To get fixes of these errors:
Step 1: You have to exclude
arm64 for simulator architecture both from your main Project and the Pod project.
- To do that for Main Project, navigate to Build Settings of your project and add
Any iOS Simulator SDKwith value
Excluded Architecture. (Note: Project, not Target. Adding to Project will automatically add settings to all its Target)
- Now, You have to do the same for the Pod project until all the cocoa pod vendors are done adding the following in their Podspec.
You can manually add the
Excluded Architechurein your Pod project's Build Settings, but it will be overwritten when you use
In place of this, you can add this snippet in your
Podfile. It will write the neccessary Build Settings every time you run
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
Step 2: You should do is delete VALID_ARCHS from your project altogether (Main Project & Pod Project Both), and make sure Architectures (ARCHS) is set to Standard Architectures (ARCHS_STANDARD) and not to something specific (unless you really know exactly why you’re not using ARCHS_STANDARD).
Please make sure you have followed both steps, then Clean the project and Re-Build it, hope these steps work for all.
Still, in case errors not got fixed by performing above Steps, then additionally you need to do following:
- You need to Upgrade all your Pods to the latest version available (Below code snippet is for your help) -> Clean Project ->Re-Build.
rm -rf ~/Library/Developer/Xcode/DerivedData/
- Still, Issues are there then you also need to Update React-Native latest version to your project.