在iOS開發中常常遇到的一個錯誤是Undefined symbols for architecture arm64
,這個錯誤表示工程某些地方不支持arm64指令集
。那咱們應該怎麼解決這個問題了?咱們不只要解決這個問題,更要了解出現這個問題的根源.這樣根本上杜絕這類問題發生.html
對於iOS設備來講iOS的指令集有armv六、armv七、armv7s、arm64
這樣四種,不一樣型號的iOS設備使用不一樣的指令集,下面是各自的區別:ios
armv6
armv7
armv7s
arm64
在Xcode的target->Build Settings
中有一個Architectures的分組主要是用來設置Architectures方面的內容,下面重點介紹下面幾個設置項的內容。git
該編譯選項指定了工程將被編譯成支持哪些指令集,支持指令集是經過編譯生成對應的二進制數據包實現的,若是支持的指令集數目有多個,就會編譯出包含多個指令集代碼的數據包,形成最終編譯的包很大。github
官方文檔說明:xcode
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.架構
該編譯項用於設置是否只編譯當前使用的設備對應的arm指令集。app
當該選項設置成YES時,你連上一個armv7指令集的設備,就算你的Valid Architectures和Architectures都設置成armv7/armv7s/arm64,仍是依然只會生成一個armv7指令集的二進制包。ide
固然該選項起做用的前提是你的Xcode必須成功鏈接了調試設備。若是你沒有任何活躍設備,即Xcode沒有成功鏈接調試設備,就算該設置項設置成YES依然還會編譯Valid Architectures和Architectures指定的二進制包。網站
一般狀況下,該編譯選項在Debug模式都設成YES,Release模式都設成NO。ui
官方文檔說明:
Boolean value. Specifies whether the product includes only object code for the native architecture.
該編譯項指定可能支持的指令集,該列表和Architectures列表的交集,將是Xcode最終生成二進制包所支持的指令集。
好比將Valid Architectures設置支持的arm指令集版本有:armv七、armv7s、arm64,對應的Architectures設置的支持arm指令集版本有:armv7s,這時Xcode只會生成一個armv7s指令集的二進制包。
官方文檔說明:
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.
一、指令集是向下兼容的。好比,armv7s指令集的設備,能夠兼容運行使用armv七、armv6編譯的程序。
看,它忽略了那個靜態庫文件致使連接失敗了,而後我查看了靜態庫所支持的架構,打開終端輸入查看命令lipo - info xxx.a ,結果以下:
發現了這個靜態庫只支持armv7 armv7s i386 . 而在個人工程中Valid Architectures和Architectures中均包含了arm64的指令集,這就是說明我須要編譯的app最終要支持arm64的,而程序中用到的靜態庫並無arm64,因此才致使了出錯,所以,須要咱們去從新下載一個支持arm64的靜態庫文件,那麼就能夠正常編譯經過了.
一、《Xcode設置項之Architectures和Valid Architectures》
三、《64-Bit Transition Guide for Cocoa Touch》
四、 iOS開發之Architectures設置