Error compiling Xcode 12 (While running with simulator iOS 14)

Tram Ho

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 / 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:

  1. Architecture support arm64 & and Xcode 12 Compatible version is not yet provided by many popular third party libraries (Like Firebase, AFNetworking, etc).

  1. 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.

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.

Share the news now

Source : Viblo