1.以如下錯(cuò)誤為例,如果是多人開發(fā),你同步完成后發(fā)現(xiàn)出現(xiàn)如下的錯(cuò)誤。
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_MyPageLogViewController", referenced from:
objc-class-ref in BaiduMobStatAppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
錯(cuò)誤中出現(xiàn)了“MyPageLogViewController”這個(gè)類,你可以找到這個(gè)類的.m文件, 查看他的Target Membeship, 如下圖
如果沒有勾選上,點(diǎn)擊勾選。然后編譯查看。
2. 如果是新添加的第三方庫,且不是靜態(tài)庫
先重復(fù)第一步過程,然后找到 Build settings->Linking->Other Linker Flags
將此屬性修改成-all_load? 或者 -ObjC ,這個(gè)視情況而定??傊梢远嘣噹状巍?/p>
3.如果添加的是第三方靜態(tài)庫(.a文件)
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_BaiduMobStat", referenced from:
objc-class-ref in BaiduMobStatAppDelegate.o
objc-class-ref in MyPageLogViewController.o
(maybe you meant: _OBJC_CLASS_$_BaiduMobStatAppDelegate)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
在用到這個(gè)庫的所有文件中都出現(xiàn)了錯(cuò)誤, 如上 BaiduMobStatAppDelegate 類和 MyPageLogViewController類
這種情況就可能是這個(gè)靜態(tài)庫路徑混亂導(dǎo)致的鏈接錯(cuò)誤
解決方法:Build settings->Search Path->Library Search Paths? 添加靜態(tài)庫的相應(yīng)路徑。如下圖
如果上面的所有方法都不管用。你可以再試試一下幾個(gè)方法:
1,看看是不是有新添加的文件跟之前文件同名
2,錯(cuò)誤信息中出現(xiàn)了某個(gè)類的名字,去原文件中看看#import了哪些第三方庫,把這些庫挨個(gè)注釋排除,找到出錯(cuò)的那個(gè)庫,然后按照官方提供的步驟重新添加一遍。