[BUG修復]“"_OBJC_CLASS_$_***文件名", referenced from:”問題的修復

今天要把之前一個項目按新需求做更新,項目在iPad2和iPad Retina模擬器上運行都沒有問題,但是在iPad Air上運行時卻包了3個錯誤,如下圖


想來應該是64位適配的問題,在網上搜索各種解決方案無果,只好請教這個項目之前的開發人員,按他要求把Valid Architectures改爲armv7,如下圖


在運行,果然編譯成功了,那麼這個Valid Architectures和上面的Architectures是什麼東西呢?

在網上搜索到這篇文章Xcode設置項之Architectures和Valid Architectures

大意如下:

Architectures
 
官方文檔說明:
  1. 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. 
 
該編譯選項指定了工程將被編譯成支持哪些指令集,支持指令集是通過編譯生成對應的二進制數據包實現的,如果支持的指令集數目有多個,就會編譯出包含多個指令集代碼的數據包,造成最終編譯的包很大。

Valid Architectures
 
官方文檔說明:
  1. 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
 
官方文檔說明:
  1. 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版本低的指令集:armv7、armv6


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章