[英]Linker error: undefined symbols, symbols not found
I'm getting these Apple Mach-O Linker errors and I don't know how to read these things. 我收到这些Apple Mach-O Linker错误,我不知道如何阅读这些内容。 I got these error after importing "CLCredentialHeader.h" and "CLCredentialHeader.m" in my project.
在我的项目中导入“CLCredentialHeader.h”和“CLCredentialHeader.m”后出现这些错误。
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_SFHFKeychainUtils", referenced from:
objc-class-ref in CLCredentialHandler.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Make sure that SFHFKeychainUtils.m
appears in the "Compile Sources" Build Phase for your build target. 确保
SFHFKeychainUtils.m
出现在构建目标的“编译源”构建阶段中。 Sometimes, adding files to a project in Xcode doesn't add all implementation files to the appropriate targets. 有时,在Xcode中向项目添加文件不会将所有实现文件添加到适当的目标。
I get this sometimes when I drag and drop a class from another project and forget to mark "add to targets" in the window that pops up. 当我从另一个项目中拖放一个类而忘记在弹出的窗口中标记“添加到目标”时,我有时会得到这个。 I think this is a very legitimate question.
我认为这是一个非常合理的问题。 The error messages are also not very intuitive.
错误消息也不是很直观。 The solution is easy in XCode clicking on the project, and click on "Build Phases" and open the "Compile Source" then say "+".
在XCode点击项目时,解决方案很简单,点击“Build Phases”并打开“Compile Source”然后说“+”。 Here some pictures that say more then all the words.
这里有一些图片说的比所有单词更多。
So if the error looks like this, it tells me DataAccess class is undefined. 因此,如果错误看起来像这样,它告诉我DataAccess类是未定义的。
I recognize this as a class I just dragged and dropped into the project. 我认为这是一个我拖入项目的课程。 I add DataAccess.m to my project
我将DataAccess.m添加到我的项目中
Originally I could have avoided it by marking "Add to targets" 最初我可以通过标记“添加到目标”来避免它
If above answers does not work for you then check you have added Security framework. 如果上述答案对您不起作用,请检查您是否添加了安全框架。 If not then add it in Build Phase section of Targets.
如果没有,则将其添加到目标的构建阶段部分。 Should be fine then :)
应该没关系:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.