iOS学习之 Xcode设置项之Architectures和Valid Architectures

转载自 http://www.cocoachina.com/industry/20140527/8566.html html


iPhone指令集xcode

 

本文所讲的内容都是围绕iPhone的CPU指令集(想了解ARM指令集的同窗请点击这里),如今先说说不一样型号的iPhone都使用的是什么指令集:ide

ARMv8/ARM64 = iPhone 5s, iPad Air, Retina iPad Mini ARMv7s = iPhone 5, iPhone 5c, iPad 4 ARMv7  = iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini   ARMv6  = iPhone, iPhone 3G, iPod 1G/2G

 

设置你想支持的指令集工具

 

Xcode中关于生成二进制包指令集相关的设置项有如下三个:性能

 

Architecturesui

 

官方文档说明:this

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.

 

该编译选项指定了工程将被编译成支持哪些指令集,支持指令集是经过编译生成对应的二进制数据包实现的,若是支持的指令集数目有多个,就会编译出包含多个指令集代码的数据包,形成最终编译的包很大。spa

 

Valid Architectures调试

 

官方文档说明:code

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.

 

该编译项指定可能支持的指令集,该列表和Architectures列表的交集,将是Xcode最终生成二进制包所支持的指令集。

 

好比,你的Valid Architectures设置的支持arm指令集版本有:armv7/armv7s/arm64,对应的Architectures设置的支持arm指令集版本有:armv7s,这时Xcode只会生成一个armv7s指令集的二进制包。

 

Build Active Architecture Only

 

官方文档说明:

Boolean value. Specifies whether the product includes only object code for the native architecture.

 

该编译项用于设置是否只编译当前使用的设备对应的arm指令集。

 

当该选项设置成YES时,你连上一个armv7指令集的设备,就算你的Valid Architectures和Architectures都设置成armv7/armv7s/arm64,仍是依然只会生成一个armv7指令集的二进制包。

 

固然该选项起做用的前提是你的Xcode必须成功链接了调试设备。若是你没有任何活跃设备,即Xcode没有成功链接调试设备,就算该设置项设置成YES依然还会编译Valid Architectures和Architectures指定的二进制包。

 

一般状况下,该编译选项在Debug模式都设成YES,Release模式都设成NO。

 

说明

 

指令集都是能够向下兼容的

 

好比,你的设备是armv7s指令集,那么它也能够兼容运行比armv7s版本低的指令集:armv七、armv6

 

xcode对armv6指令集的支持

 

Xcode4.5起再也不支持armv6,Xcode4.5的release notes中明确指出:

Changes General: iOS  This version of Xcode does not generate armv6 binaries. 12282156 The minimum deployment target is iOS 4.3. 12282166

 

如何选择支持的指令集

 

若是你的软件对安装包大小很是敏感,你能够减小安装包中的指令集数据包,并且这能达到立竿见影的效果。

 

咱们的项目以前支持的指令集是armv7/armv7s,后来改为只支持armv7后,比原来小了10MB左右。目前AppStore上的一些知名应用,好比百度地图、腾讯地图经过反汇编工具查看后,也都只支持armv7指令集。

 

根据向下兼容原则,armv7指令集的应用是能够正常在支持armv7s/arm64指令集的机器上运行的。

 

不过对于armv7s/arm64指令集设备来讲,使用运行armv7应用是会有必定的性能损失,不过这种损失有多大缺少权威统计数据,我的认为是不会影响用户体验的。

相关文章
相关标签/搜索