在Xcode构建设置中,“架构”和“有效架构”的区别是什么?

时间:2022-05-05 13:31:41

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

它们的意义是什么,我能把它们设成不同的值吗?

2 个解决方案

#1


101  

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.

因此,您可能只想为armv7构建二进制文件,但同样的源代码也适用于armv7和armv6。VALID_ARCHS = 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.

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

and:

和:

VALID_ARCHS (Valid Architectures)

VALID_ARCHS(有效的架构)

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.

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

Source: Xcode Build Setting Reference

源代码:Xcode构建设置引用

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.

在实践中,您可以单独离开VALID_ARCHS,不必担心更改它,并且只需要修改ARCHS来设置您想要构建的体系结构。通常,您将调试构建设置为NATIVE_ARCH,因为您只想为将要测试/运行它的机器构建调试版本,并为计划支持的所有体系结构发布构建。

#2


4  

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

从Apple文档中,我们知道二进制Xcode将构建与体系结构交叉的有效架构。

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.

因此,您可能只想为armv7构建二进制文件,但同样的源代码也适用于armv7和armv6。VALID_ARCHS = 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 v7 v7,设置拱= v7,二进制Xcode将构建v7的结果,它不能兼容armv6 / v7。

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.

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

#1


101  

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.

因此,您可能只想为armv7构建二进制文件,但同样的源代码也适用于armv7和armv6。VALID_ARCHS = 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.

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

and:

和:

VALID_ARCHS (Valid Architectures)

VALID_ARCHS(有效的架构)

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.

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

Source: Xcode Build Setting Reference

源代码:Xcode构建设置引用

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.

在实践中,您可以单独离开VALID_ARCHS,不必担心更改它,并且只需要修改ARCHS来设置您想要构建的体系结构。通常,您将调试构建设置为NATIVE_ARCH,因为您只想为将要测试/运行它的机器构建调试版本,并为计划支持的所有体系结构发布构建。

#2


4  

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

从Apple文档中,我们知道二进制Xcode将构建与体系结构交叉的有效架构。

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.

因此,您可能只想为armv7构建二进制文件,但同样的源代码也适用于armv7和armv6。VALID_ARCHS = 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 v7 v7,设置拱= v7,二进制Xcode将构建v7的结果,它不能兼容armv6 / v7。

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.

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