Building for iOS Simulator, but linking in object file built for iOS, XXXX for architecture arm64

An error occurs when the original project is migrated to Xcode 12 and the simulator runs normally on the real computer

  • In Xcode 11, we passedBuild Setting -> Architectures -> Valid ArchitecturesEnter the supported instruction set
  • In Xcode 12,Valid ArchitecturesThis term gets removed and replaced byUser-DefinedIn theVALID_ARCHS

The difference is that x86_64 is added by default in Xcode 11 and is supported by default even if it is not specified. However, x86_64 is not added in Xcode 12 by default and must be manually added

A (xxxxXXX.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

“Static Architectures do not support the Simulator arm64. Add Any iOS Simulator SDK corresponding to arm64 in Build Setting -> Excluded Architectures.

C, Have the same architectures (arm64) and can’t be in the same fat output file

Xcode before 12

  • Build simulator static library supporti386,x86_64Two architecture
  • Build real machine static library supportarmv7,arm64Two architecture
  • We will generallylib -create -outputCommand to merge two libraries into one that supports all four architectures

Xcode 12 simulator static library added support for ARM64, resulting in and real static library can not merge problems

Ignore the arm64 compiled by the Simulator and add Any iOS Simulator SDK corresponding to the arm64 value in Build Setting -> Excluded Architectures

A -remove arm64-output xxx.a for the packaged. Framework lipo xxx. a

The linked library ‘XXXX. A /Framework’ is missing one or more architectures required by this target: armV7.

Add the following code to the Target -> Build Setting -> Exculded Architectures file

EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8 EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT))