(Linker command failed with exit code 1) Error summary, linkerfailed
This problem usually occurs when a third-party library file or multiple developers are added.
This problem is generally caused by a link error because the file cannot be found. We can troubleshoot from the following aspects.
1. Take the following error as an example. If it is developed by multiple people, you will find the following error after synchronization is completed.
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)
The "MyPageLogViewController" class is displayed in the error. You can find the. m file of this class and view its Target Membeship, as shown in figure
If not selected, click it. Then compile and view.
2. If it is a newly added third-party library and is not a static library
Repeat the first step and find Build settings> Linking> Other Linker Flags.
Modify this attribute to-all_load or-ObjC, depending on the situation. In short, you can try multiple times.
3. If a third-party static library (. a file) is added)
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)
Errors occur in all files used in this library, such as the BaiduMobStatAppDelegate class and MyPageLogViewController class.
In this case, the Link error may be caused by the path confusion of the static library.
Solution: Build settings-> Search Path-> Library Search Paths to add the corresponding Path of the static Library. For example
If none of the above methods are used. You can try the following methods:
1. Check whether the newly added file has the same name as the previous file.
2. The error message contains the name of a class. Go to the original file and check # which third-party libraries have been imported. Comment out these libraries one by one and find the database with the error, then, follow the official steps to add it again.