one of the common mistakes that you'll encounter in iOS development isUndefined symbols for architecture arm64
, this error indicates that some parts of the project do not supportarm64指令集
. ThatHow are we going to solve this problem? We should not only solve this problem, but also understand the root cause of the problem. This essentially eliminates such problems.
iOS instruction set for iOS devices has armv6, ARMv7, armv7s, arm64
four different types of iOS devices use different instruction sets, the following are the differences:
armv6
- iphone, IPhone 3G
- ipod 1G, IPod 2G
armv7
- iphone 3GS, IPhone 4
- ipod 3G, ipod 4G, ipod 5G
- ipad, ipad 2, ipad 3, ipad Mini
armv7s
- iphone 5, IPhone 5 c
- ipad 4
arm64
- iphone 5S iphone 6   iphone 6Plus
- ipad Air, Retina iPad Mini
target->build Settings
has a architectures grouping is primarily used to set the architectures aspect of the content, The following highlights the contents of the following settings.
Architectures
This compilation option specifies which instruction sets the project will be compiled to support, which is implemented by compiling the corresponding binary packets, and if there are multiple supported instruction sets, the packets containing multiple instruction set codes will be compiled, resulting in a large number of final compilations.
Official Document Description:
space-separated List of identifiers. Specifies the architectures (ABIs, processor models) to which the binary is targeted. When this builds setting specifies more than one architecture, the generated binary could contain object code for each of the Specified architectures.
Build Active Architectures only
This compilation is used to set whether to compile only the arm instruction set for the device that is currently in use.
When this option is set to Yes, you connect to a device on a armv7 instruction set, even if your valid architectures and architectures are set to armv7/armv7s/arm64, Still, only a binary package of the ARMV7 instruction set will be generated.
Of course this option works if your Xcode must successfully connect to the debug device. If you do not have any active devices, that is, Xcode does not successfully connect to the debug device, even if the setting entry is set to Yes, the binary packages specified by valid architectures and architectures are also compiled.
Typically, this compilation option is set to Yes,release mode in debug mode to No.
Official Document Description:
Boolean value. Specifies whether the product includes only object code for the native architecture.
Valid architectures
This compilation specifies the set of instructions that may be supported, and the intersection of the list and the architectures list will be the set of instructions supported by Xcode to eventually generate the binary package.
For example, the valid architectures set supported ARM instruction set version has: ARMv7, armv7s, arm64, corresponding architectures settings support ARM instruction set version has: Armv7s, Then Xcode will only generate a binary package of the armv7s instruction set.
Official Document Description:
space-separated List of identifiers. Specifies the architectures for which the binary is built. During the build, this list was intersected with the value of archs build setting; The resulting list specifies the architectures the binary can run on. If The resulting architecture list is empty, the target generates no binary.
Description
1, instruction set is backward-compatible. For example, the armv7s instruction set of the device, can be run with ARMV7, ARMV6 compiled program.
Examplein the project, the use of third-party social sharing static library is the time, will compile the failure, first look at
See, it ignores that static library file causes the link to fail, then I look at the schema supported by the static library, open the Terminal input View command Lipo-info XXX.A, the result is as follows:
This static library was found to support only armv7 armv7s i386. And in my project valid architectures and architectures contain the arm64 instruction set, this means that I need to compile the app eventually to support Arm64, and the application of the static library does not arm64, so it caused the error, so , we need to re-download a static library file that supports arm64, then it can be compiled and passed normally.
Reference documents
1. Architectures and valid architectures of Xcode settings
2, "Xcode5 arm64"
3, "64-bit Transition Guide for Cocoa Touch"
4, iOS development architectures settings
5. Xcode settings architectures and valid architectures
6. Architecture Overview in Xcode Build settings
Undefined Symbols for Architecture arm64 solution