macos 如何使用 xcodebuild 构建特定架构?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6151549/
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
How can I build a specific architecture using xcodebuild?
提问by pqnet
I have legacy code that relies on pointers being 32-bit
and want to use xCodeBuild
to build that code from command line
. This doesn't work for some reason. Here's the command I use:
我有依赖于指针的遗留代码,32-bit
并希望用于xCodeBuild
从command line
. 由于某种原因,这不起作用。这是我使用的命令:
xcodebuild -configuration Debug -arch i386
-workspace MyProject.xcworkspace -scheme MyLib
here's the output I get
这是我得到的输出
[BEROR]No architectures to compile for
(ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
Clearly it's trying to build x86_64
code and failing miserably since I only enabled i386
from VALID_ARCHS
in xCode project settings.
显然,它试图建立x86_64
的代码和失败草草收场,因为我只启用i386
从VALID_ARCHS
Xcode中的项目设置。
Is there a way to make it understand I don't want a 64-bit
library?
有没有办法让它明白我不想要一个64-bit
图书馆?
回答by Laurent Etiemble
You have to set the ONLY_ACTIVE_ARCH
to NO
if you want xcodebuild
to use the ARCHS
parameters. By passing these parameters, you can force the proper architecture.
如果要使用参数ONLY_ACTIVE_ARCH
,NO
则必须设置为。通过传递这些参数,您可以强制使用正确的架构。xcodebuild
ARCHS
xcodebuild ARCHS=i386 ONLY_ACTIVE_ARCH=NO -configuration Debug -workspace MyProject.xcworkspace -scheme MyLib
See this referencefor details.
有关详细信息,请参阅此参考资料。
回答by yoAlex5
xcodebuild ONLY_ACTIVE_ARCH...
//or
Build Settings -> Build Active Architecture Only -> ONLY_ACTIVE_ARCH
YES
- build binary with a single architecture for a connected device
YES
- 为连接的设备构建具有单一架构的二进制文件
NO
- build binary for a specific -arch
(valid architectures
aka VALID_ARCHS
) if it was specified or for all the architectures in other cases
NO
- 为特定-arch
(valid architectures
又名VALID_ARCHS
)构建二进制文件(如果已指定)或其他情况下的所有体系结构
The recommendation is to use Yes
for Debug(it save a build time) and No for Release build.
建议Yes
用于 Debug(它节省构建时间)和 No 用于发布构建。
Note: it is safety to run on simulator
注意:在模拟器上运行是安全的
To check the version use lipo -info
[About]
要检查版本使用lipo -info
[关于]