Building a large project on Xcode Version 12.0.1 (12A7300) with a simulator selected (iOS 14) caused various bugs, even though the same project worked perfectly with Xcode 11.x and lower versions or not.
Note: The tested project is a large one with many popular third-party cocoapods libraries [Swift + objC] AFNetworking, Firebase, RN Modules, Notification Extension target, etc.
Some errors are as follows:
- 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 want you to see the important update from the Xcode 12 Release Notes:
Here are the 2 main reasons for the errors resulting from this change:
- Architecture support arm64 & and Xcode 12 Compatible version is not yet provided by many popular third party libraries (Like Firebase, AFNetworking, etc).
1 2 3 | 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. |
- Since the Valid Architectures settings are removed in Xcode 12, so the project in Xcode 12 will automatically generate the VALID_ARCHS macro in User-Defines, and this macro will cause the build to fail.
Steps to fix these errors:
Step 1: You must exclude arm64 for the emulator architecture both from your Project and Pod.
- To do that for Project, navigate to the Build Settings of the project and add “Any iOS Simulator SDK” which has an arm64 value inside “Excluded Architecture”. (Note: Project, not Target. Adding to Project automatically adds settings to all of its Target’s.)
- Now, you have to do the same for the Pod project until all the cocoapods vendors have finished adding the following to their Podspec.
1 2 3 | Bạn có thể thêm thủ công Excluded Architechure trong Build Settings của dự án Pod của mình, nhưng nó sẽ bị ghi đè khi bạn sử dụng cài đặt pod. Thay vào đó, bạn có thể thêm đoạn mã này vào Podfile của mình. Nó sẽ viết Build Settings cần thiết mỗi khi bạn chạy cài đặt pod |
1 2 3 4 5 6 | post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end |
Step 2: You should do is remove VALID_ARCHS completely from your project (Main Project & Pod Project) and make sure Architecture (ARCHS) is set to Standard Architectures (ARCHS_STANDARD) and not something specific (except when you really know exactly why you’re ‘not using ARCHS_STANDARD).
[image 7]
Please make sure you’ve followed both steps, then Clean the project and rebuild it, hoping these steps worked for all.
However, in case the error is not solved by performing the Steps above, then you need to do the following additional steps:
- You need to Upgrade all your Pods to the latest available version (The snippet below is for your help) -> Clean Project -> Re-Build.
1 2 3 4 | rm -rf ~/Library/Developer/Xcode/DerivedData/ pod deintegrate pod update |