iOS关于armv7,armv7s,arm64,i386,x86_64等问题
iOS測(cè)試分為模擬器測(cè)試和真機(jī)測(cè)試,處理器分為32位處理器,和64位處理器,
模擬器32位處理器測(cè)試需要i386架構(gòu),(iphone5,iphone5s以下的模擬器)
模擬器64位處理器測(cè)試需要x86_64架構(gòu),(iphone6以上的模擬器)
真機(jī)32位處理器需要armv7,或者armv7s架構(gòu),(iphone4真機(jī)/armv7, ? ? ?ipnone5,iphone5s真機(jī)/armv7s)
真機(jī)64位處理器需要arm64架構(gòu)。(iphone6,iphone6p以上的真機(jī))
project -> target -> building setting -> Arhitectures 設(shè)置
debug屬性設(shè)置為no的時(shí)候,會(huì)編譯支持所有架構(gòu)的版本,編譯的速度會(huì)變慢,設(shè)置為yes 的時(shí)候,只編譯當(dāng)前的architecture版本,編譯速度快。
一般情況下,debug 設(shè)置為yes,release為no,這樣發(fā)行版本能適應(yīng)不同設(shè)備,
Undefined symbols錯(cuò)誤的解決方案整理
? ? ? .h(聲明文件)<————>.m(實(shí)現(xiàn)文件)
? ? ? ? ? ? ? ? ? ? ? ? ?.h<————>.c
? ? ? ? ? ? ? ? ? ? .hpp<————>.cpp
? ? ?1》在源代碼中,找不到一個(gè)標(biāo)識(shí)符的聲明,無論是變量名,類名,或者是方法名,編譯的時(shí)候會(huì)得到
Use of undeclared identifier ‘XXX’錯(cuò)誤。
2》在源代碼中,如果編譯器找到他的聲明,卻不知道他怎么實(shí)現(xiàn)的,或者說目標(biāo)文件里沒有這個(gè)實(shí)現(xiàn),則就會(huì)出現(xiàn)鏈接錯(cuò)誤。Undefined symbols for architecture armv7(armv7處理器架構(gòu)指令集下,符號(hào)未定義):
? "_XCloseIM", referenced from:
? ? ? dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in gui_core_kernel_2.o
編譯原理,在源碼詞法分析,語法分析以及編譯的整個(gè)過程中,會(huì)生成符號(hào)表,所有標(biāo)識(shí)符都會(huì)放到這個(gè)表中。 如果鏈接的時(shí)候,找不到具體的實(shí)現(xiàn),就會(huì)出現(xiàn)這個(gè)錯(cuò)誤。可能的原因有:
- 引入了需要用到的庫的頭文件,卻沒有鏈接正確的實(shí)現(xiàn)庫。因?yàn)閄code本身所支持的庫是Static Library,即.a的方式,.a的文件里只有實(shí)現(xiàn),使用的時(shí)候需要另外引入頭文件,那么就有可能把頭文件放進(jìn)來,沒有放.a或放入了錯(cuò)誤的版本。
- Build Settings或者Build Phases配置有誤。檢查Build Phases里的Link Binary With Libraries和Build Settings里的幾項(xiàng)Search Path。
- 從外部導(dǎo)入的文件沒有加入到特定的target中。這個(gè)正是我整理這篇日志之前遇到的,將.a、.m、.framework等引入到工程當(dāng)中,卻沒有勾選當(dāng)前Build的target,會(huì)出現(xiàn)這個(gè)問題,可以選中特定的文件,在右側(cè)邊欄中選中target。
- 未包含處理器架構(gòu)指令集的問題。報(bào)錯(cuò)時(shí)的提示一般都是“Undefined symbols for architecture armv7”之類的,而“for architecture armv7”就是說沒有支持armv7,在Build settings里architecture相關(guān)的幾項(xiàng)需要配置正確。
當(dāng)源碼運(yùn)行出現(xiàn)這種錯(cuò),解決辦法是target-->build setting-->compile sources as 把混編語言改回objective-c 就可以了
Undefined symbols for architecture armv7:
? "_UIApplicationMain", referenced from:
? ? ? _main in main.o
? "_OBJC_CLASS_$_UIResponder", referenced from:
? ? ? _OBJC_CLASS_$_AppDelegate in AppDelegate.o
? "_OBJC_METACLASS_$_UIViewController", referenced from:
? ? ? _OBJC_METACLASS_$_ViewController in ViewController.o
? "_OBJC_CLASS_$_UINavigationController", referenced from:
? ? ? objc-class-ref in AppDelegate.o
? "_OBJC_CLASS_$_UIWindow", referenced from:
? ? ? objc-class-ref in AppDelegate.o
? "_OBJC_CLASS_$_UIScreen", referenced from:
? ? ? objc-class-ref in AppDelegate.o
? "_OBJC_METACLASS_$_UIResponder", referenced from:
? ? ? _OBJC_METACLASS_$_AppDelegate in AppDelegate.o
? "_OBJC_CLASS_$_UIViewController", referenced from:
? ? ? _OBJC_CLASS_$_ViewController in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的iOS关于armv7,armv7s,arm64,i386,x86_64等问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# 两个类之间传递数据
- 下一篇: 三大运营商布局金融的套路不同,还能否搭上