xcode 单元测试中的“架构 i386 的未定义符号”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11848705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Undefined symbols for architecture i386" on unit tests
提问by hpique
I'm getting the following error only when I try to build the unit tests of an iPhone static library:
仅当我尝试构建 iPhone 静态库的单元测试时,才会收到以下错误:
Undefined symbols for architecture i386:
"std::terminate()", referenced from:
-[ZipArchive dealloc] in libMyProject.a(ZipArchive.o)
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in libMyProject.a(ZipArchive.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Building the original project works fine.
构建原始项目工作正常。
What can I be missing?
我能缺少什么?
It should be noted that ZipArchive is a .mm file that references the libz.dylibframework, which is referenced both in the original project and in the test project.
需要注意的是,ZipArchive是一个引用libz.dylib框架的.mm文件,在原始项目和测试项目中都被引用。
Additionally, the usual Build Settings suspects have the following values:
此外,通常的构建设置疑点具有以下值:
Framework Search Paths: "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"
框架搜索路径:“$(SDKROOT)/Developer/Library/Frameworks”“$(DEVELOPER_LIBRARY_DIR)/Frameworks”
Other Linker Flags: -all_load -lxml2 - ObjC
其他链接器标志:-all_load -lxml2 - ObjC
Header Search Paths: /usr/include/libxml2
标题搜索路径:/usr/include/libxml2
回答by hpique
回答by Jesse Gumpo
This typically occurs for one of two reasons:
这通常是由于以下两个原因之一而发生的:
- You copied a framework or system header directly to your project folder instead of addingit with a reference through XCode
- You've installed multiple SDKs, and the wrong framework or header is being referenced. Most frameworks aren't "Developer" frameworks. SenTestingKit.framework is an example of a developer framework, UIKit.framework isn't. Oddly, there are two different places that Developer Frameworks exist. In the /Developers/~ folder in XCode, and also in the SDK Developers folder. The default behavior is to reference the framework in XCode's developer folder. To override this, enter "$(SDKROOT)/Developer/Library/Frameworks" in "Framework Search Paths". Or in the case of an imported header or library, go the corresponding field and add "$(SDKROOT)/..."
- 您将框架或系统头文件直接复制到您的项目文件夹中,而不是通过 XCode添加引用
- 您安装了多个 SDK,并且引用了错误的框架或标头。大多数框架都不是“开发人员”框架。SenTestingKit.framework 是一个开发者框架的例子,而 UIKit.framework 不是。奇怪的是,Developer Frameworks 存在于两个不同的地方。在 XCode 的 /Developers/~ 文件夹中,也在 SDK Developers 文件夹中。默认行为是引用 XCode 的开发者文件夹中的框架。要覆盖它,请在“框架搜索路径”中输入“$(SDKROOT)/Developer/Library/Frameworks”。或者在导入的头文件或库的情况下,转到相应的字段并添加“$(SDKROOT)/...”
Make sure your search paths are the samecorrect for all Targets:
确保所有目标的搜索路径都相同:
If you are using multiple SDKs, the wrong version of the Developer Frameworks could get added (like SenTestingKit). Manually enter the the correct one under Framework Search Paths with
如果您使用多个 SDK,可能会添加错误版本的开发人员框架(如 SenTestingKit)。在 Framework Search Paths 下手动输入正确的
$(SDKROOT)/Developer/Library/Frameworks
$(SDKROOT)/开发者/库/框架