Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between "Architectures" and "Valid Architectures" in Xcode Build Settings?

People also ask

Where is valid architectures in Xcode?

If a project includes VALID_ARCHS, the setting is displayed in the User-Defined section of the Build Settings editor.

What is build active architecture only Xcode?

The "build active architecture only" setting causes everything except the current Mac's architecture to be ignored (and the current one is of course valid), hiding the problem. Instead, you should look up a row or two in the settings, and change the "Architectures" setting to "Standard".

Is missing one or more architectures required by this target x86_64?

framework' is missing one or more architectures required by this target: x86_64. This can happen when switching between simulator versions on a Cocoapods project. Cleaning the project should fix the issue. This error occurs when a arm64 iPhoneSimulator slice cannot be found for one of your binary dependencies.


Architectures are the ones you want to build, valid architectures are the ones you could conceive of building with your codebase.

So maybe you only want to build your binary for armv7s, but the same source code would compile fine for armv7 and armv6. So VALID_ARCHS = armv6 armv7 armv7s, but you set ARCHS = armv7s because that's all you actually want to build with your code.

Or, in Apple-ese:

ARCHS (Architectures)

Space-separated list of identifiers. Specifies the architectures (ABIs, processor models) to which the binary is targeted. When this build setting specifies more than one architecture, the generated binary may contain object code for each of the specified architectures.

and:

VALID_ARCHS (Valid Architectures)

Space-separated list of identifiers. Specifies the architectures for which the binary may be built. During the build, this list is 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.

Source: Xcode Build Setting Reference

In practice, you leave VALID_ARCHS alone and don't worry about changing it, and just fiddle with ARCHS to set the architectures you want to build. Typically, you set a Debug build to just NATIVE_ARCH, since you only want to build the debug version for the machine you'll be testing/running it on, and Release builds for the full spectrum of architectures you plan to support.


From Apple document,we know that the binary Xcode will build is the list Valid Architectures intersected with Architectures.

So ,i don't think Jeremy's answer is right, as he say:

So maybe you only want to build your binary for armv7s, but the same source code would
compile fine for armv7 and armv6. So VALID_ARCHS = armv6 armv7 armv7s, but you set ARCHS = armv7s because that's all you actually want to build with your code.

When you set VALID_ARCHS = armv6 armv7 armv7s,and set ARCHS = armv7s,the result of binary Xcode will build is armv7s,it could not compatible with armv6/armv7.

And if you want to compatible with armv6/armv7/armv7s,you must set VALID_ARCHS = armv6 armv7 armv7s and ARCHS = armv6.In this way , the result of binary Xcode will build is armv6, and it can run fine on both armv6/armv7/armv7s as arm processor is backwards compatible.