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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:05:23  来源:igfitidea点击:

How can I build a specific architecture using xcodebuild?

macoscommand-linexcode4xcodebuild

提问by pqnet

I have legacy code that relies on pointers being 32-bitand want to use xCodeBuildto build that code from command line. This doesn't work for some reason. Here's the command I use:

我有依赖于指针的遗留代码,32-bit并希望用于xCodeBuildcommand 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_64code and failing miserably since I only enabled i386from VALID_ARCHSin xCode project settings.

显然,它试图建立x86_64的代码和失败草草收场,因为我只启用i386VALID_ARCHSXcode中的项目设置。

Is there a way to make it understand I don't want a 64-bitlibrary?

有没有办法让它明白我不想要一个64-bit图书馆?

回答by Laurent Etiemble

You have to set the ONLY_ACTIVE_ARCHto NOif you want xcodebuildto use the ARCHSparameters. By passing these parameters, you can force the proper architecture.

如果要使用参数ONLY_ACTIVE_ARCHNO则必须设置为。通过传递这些参数,您可以强制使用正确的架构。xcodebuildARCHS

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 architecturesaka VALID_ARCHS) if it was specified or for all the architectures in other cases

NO- 为特定-archvalid architectures又名VALID_ARCHS)构建二进制文件(如果已指定)或其他情况下的所有体系结构

The recommendation is to use Yesfor Debug(it save a build time) and No for Release build.

建议Yes用于 Debug(它节省构建时间)和 No 用于发布构建。

enter image description here

在此处输入图片说明

Note: it is safety to run on simulator

注意:在模拟器上运行是安全的

To check the version use lipo -info[About]

要检查版本使用lipo -info[关于]