Architectures&Valid Architectures,及xcodebuild -arch

指令集相关的两个配置项


Valid Architectures (VALID_ARCHS)

A space-separated list of architectures for which the target should actually be built. For each target, this is intersected with the list specified in Architectures (ARCHS), and the resulting set is built. This allows individual targets to opt out of building for particular architectures. If the resulting set of architectures is empty, no executable will be produced.

Architectures (ARCHS)

A list of the architectures for which the product will be built. This is usually set to a predefined build setting provided by the platform. If more than one architecture is specified, a universal binary will be produced.

以上是摘自Xcode Help里关于Architectures和Valid Architectures这两个构建设置项的英文描述,可参照https://help.apple.com/xcode/mac/10.2/#/itcaec37c2a6?sub=devf0a9d5aca

设计目的

这两项设置最终决定了构建产物所支持的指令集,即它们所包含的指令集的交集。

  • Valid Architectures (VALID_ARCHS)
    有效的指令集,用来给对应的target设置有效指令集范围。我们在打包时支持的指令集越多,包的体积几乎是按倍数增加,基于这方面的考虑,苹果提供了此项配置用于剔除低版本CUP指令集的支持。另外,在设计原则上所有指令集是向下兼容的,高版本运行低版本指令集时达不到应该有的性能,如果包体积大小的权重高的话也可以采取牺牲性能来达到期望目的,比如用armv7来取代armv7s。
  • Architectures (ARCHS)
    目标指令集,只有设置成有效的(即Valid Architectures (VALID_ARCHS) 所包含的)才会起作用。

与xcodebuild相关

默认情况下xcodebuild会读取BuildSetting里的配置项,但是我们也可以用构建命令的option -arch来指定需要的指令集,而且会覆盖项目中设置的。-arch的说明可以是xcodebuild --help查看。

-arch ARCH                                               
build each target for the architecture ARCH; this will override architectures defined in the project

多个指令集构建时,追加多个-arch即可,如下:

xcodebuild -target ${target_Name} -configuration Release -sdk iphoneos -arch armv7s -arch arm64
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 8,250评论 0赞 10
  • 接上篇,我们要制作一个通用的.a文件。 先上理论知识: 一、概要 平时项目开发中,可能使用第三方提供的静态库.a,...
    _烩面_阅读 607评论 0赞 2
  • 李万京 漫山涌绿,白浪奔流。中流砥石,如削似磨。拾级而上,如入画屏。 夹山送青,横轲迎面。 移步换景,目不暇接:汩...
    满江枫飞阅读 498评论 0赞 3
  • 1 高三那年,我以全班正数第一的身份,来到了全校学生垂涎三尺的尖子生班,光荣的成为了尖子班里的正数第六十名,倒数第...
    恶童阅读 1,390评论 19赞 14
  • 写文章说真的不知该怎么去写,生活中有很多故事,想全写下来,却发现自己的文笔实在是不怎么样,今天翻开日记本忽然发现前...
    戈壁滩上的一颗胡杨阅读 321评论 6赞 2

友情链接更多精彩内容