ios Xcode 构建设置中的“架构”和“有效架构”之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12701188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:35:25  来源:igfitidea点击:

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

iosxcodexcode4.5

提问by northtree

What's the meaning of them and can I set them in different values?

它们的含义是什么,我可以将它们设置为不同的值吗?

回答by Jeremy W. Sherman

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 = armv7sbecause that's all you actually wantto build with your code.

因此,也许您只想为 armv7s 构建二进制文件,但相同的源代码可以为 armv7 和 armv6 编译良好。所以VALID_ARCHS = armv6 armv7 armv7s,但是你设置了,ARCHS = armv7s因为这就是你真正想要用你的代码构建的。

Or, in Apple-ese:

或者,在 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.

ARCHS(建筑)

以空格分隔的标识符列表。指定二进制文件所针对的体系结构(ABI、处理器模型)。当此构建设置指定多个架构时,生成的二进制文件可能包含每个指定架构的目标代码。

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.

VALID_ARCHS(有效架构)

以空格分隔的标识符列表。指定可以为其构建二进制文件的体系结构。在构建过程中,此列表与 ARCHS 构建设置的值相交;结果列表指定了二进制文件可以运行的架构。如果生成的架构列表为空,则目标不会生成二进制文件。

Source: Xcode Build Setting Reference

来源:Xcode 构建设置参考

In practice, you leave VALID_ARCHSalone and don't worry about changing it, and just fiddle with ARCHSto 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.

在实践中,您VALID_ARCHS不必担心更改它,只需摆弄ARCHS以设置您想要构建的架构。通常,您将 Debug 构建设置为 just NATIVE_ARCH,因为您只想为您将在其上测试/运行它的机器构建调试版本,并为您计划支持的所有体系结构构建 Release 构建。

回答by foogry

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

从 Apple 文档中,我们知道 Xcode 将构建的二进制文件是Valid ArchitecturesArchitectures.

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

所以,我不认为 Jeremy 的回答是正确的,正如他所说:

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.

因此,也许您只想为 armv7s 构建二进制文件,但相同的源代码可以
为 armv7 和 armv6 编译良好。所以VALID_ARCHS = armv6 armv7 armv7s,但是你设置了 ARCHS = armv7s 因为这就是你真正想要用你的代码构建的。

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.

当你设置VALID_ARCHS = armv6 armv7 armv7s, 和 set 时ARCHS = armv7s,二进制 Xcode 将构建的结果是 armv7s,它无法兼容 armv6/armv7。

And if you want to compatible with armv6/armv7/armv7s,you must set VALID_ARCHS = armv6 armv7 armv7sand 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.

并且如果你想兼容armv6/armv7/armv7s,你必须设置 VALID_ARCHS = armv6 armv7 armv7sARCHS = armv6。这样,二进制Xcode构建的结果是armv6,并且它可以在armv6/armv7/armv7s上正常运行,因为arm处理器是向后兼容的.