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應用是會有必定的性能損失,不過這種損失有多大缺少權威統計數據,我的認爲是不會影響用戶體驗的。

相關文章
相關標籤/搜索