1、ARM
ARM處理器,特點(diǎn)是體積小、低功耗、低成本、高性能,所以幾乎所有手機(jī)處理器都基于ARM,在嵌入式系統(tǒng)中應(yīng)用廣泛。
2、ARM處理器指令集
armv6|armv7|armv7s|arm64都是ARM處理器的指令集,這些指令集都是向下兼容的,例如armv7指令集兼容armv6,只是使用armv6的時(shí)候無法發(fā)揮出其性能,無法使用armv7的新特性,從而會(huì)導(dǎo)致程序執(zhí)行效率沒那么高。
還有兩個(gè)我們也很熟悉的指令集:i386|x86_64 是Mac處理器的指令集,i386是針對(duì)intel通用微處理器32架構(gòu)的。x86_64是針對(duì)x86架構(gòu)的64位處理器。所以當(dāng)使用iOS模擬器的時(shí)候會(huì)遇到i386|x86_64,ios模擬器沒有arm指令集。
3、目前iOS移動(dòng)設(shè)備指令集
?arm64:iPhone6s | iphone6s plus|iPhone6| iPhone6 plus|iPhone5S | iPad Air| iPad mini2(iPad mini with Retina Display)
armv7s:iPhone5|iPhone5C|iPad4(iPad with Retina Display)
armv7:iPhone4|iPhone4S|iPad|iPad2|iPad3(The New iPad)|iPad mini|iPod Touch 3G|iPod Touch4
模擬器32位處理器測(cè)試需要i386架構(gòu)
模擬器64位處理器測(cè)試需要x86_64架構(gòu)
真機(jī)32位處理器需要armv7,或者armv7s架構(gòu)
真機(jī)64位處理器需要arm64架構(gòu)
4、Xcode中指令集相關(guān)選項(xiàng)(Build Setting中)
(1)Architectures
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.?
指定工程被編譯成可支持哪些指令集類型,而支持的指令集越多,就會(huì)編譯出包含多個(gè)指令集代碼的數(shù)據(jù)包,對(duì)應(yīng)生成二進(jìn)制包就越大,也就是ipa包會(huì)變大。
(2)Valid Architectures
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.?
限制可能被支持的指令集的范圍,也就是Xcode編譯出來的二進(jìn)制包類型最終從這些類型產(chǎn)生,而編譯出哪種指令集的包,將由Architectures與Valid Architectures(因此這個(gè)不能為空)的交集來確定,例如:
比如,你的Valid Architectures設(shè)置的支持arm指令集版本有:armv7/armv7s/arm64,對(duì)應(yīng)的Architectures設(shè)置的支持arm指令集版本有:armv7s,這時(shí)Xcode只會(huì)生成一個(gè)armv7s指令集的二進(jìn)制包。
再比如:將Architectures支持arm指令集設(shè)置為:armv7,armv7s,對(duì)應(yīng)的Valid Architectures的支持的指令集設(shè)置為:armv7s,arm64,那么此時(shí),XCode生成二進(jìn)制包所支持的指令集只有armv7s
在Xcode9.2里的 Valid Architectures ?設(shè)置里, 默認(rèn)為 Standard architectures(armv7,armv7s,arm64)
(3)Build Active Architecture Only
指定是否只對(duì)當(dāng)前連接設(shè)備所支持的指令集編譯
當(dāng)其值設(shè)置為YES,這個(gè)屬性設(shè)置為yes,是為了debug的時(shí)候編譯速度更快,它只編譯當(dāng)前的architecture版本,而設(shè)置為no時(shí),會(huì)編譯所有的版本。 編譯出的版本是向下兼容的,連接的設(shè)備的指令集匹配是由高到低(arm64 > armv7s > armv7)依次匹配的。比如你設(shè)置此值為yes,用iphone4編譯出來的是armv7版本的,iphone5也可以運(yùn)行,但是armv6的設(shè)備就不能運(yùn)行。 ?所以,一般debug的時(shí)候可以選擇設(shè)置為yes,release的時(shí)候要改為no,以適應(yīng)不同設(shè)備。?
通過終端合并,lipo -create 靜態(tài)庫路徑1 靜態(tài)庫2 -output 靜態(tài)庫路徑3 ,合并完的靜態(tài)庫3的大小=靜態(tài)庫1+靜態(tài)庫2
記錄積累~~