架构 x86_64 的 Xcode 9 未定义符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46418947/
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
Xcode 9 undefined symbols for architecture x86_64
提问by Jozef Vrana
after switching to Xcode 9 I am getting errors, it looks like this.
切换到 Xcode 9 后出现错误,看起来像这样。
I blanked the project and classes names, but there is a list of classess ending with .o suffix. In Xcode 8.3.2 everything works. I got 2 projects, one is library that is building without problems. Another project is test app, that is pointing to the library by :path directive in Podfile. In both projects build settings -> architectures is set to standard arichitectures, build active architectures only is set to DEBUG: Yes, RELEASE: No. Have you come across this problem? Thanks upfront for the help.
我清除了项目和类名称,但有一个以 .o 后缀结尾的类列表。在 Xcode 8.3.2 中一切正常。我有 2 个项目,一个是正在建设中没有问题的图书馆。另一个项目是测试应用程序,它通过 Podfile 中的 :path 指令指向库。在这两个项目中,构建设置 -> 架构设置为标准架构,仅构建活动架构设置为调试:是的,发布:否。您遇到过这个问题吗?预先感谢您的帮助。
采纳答案by Jozef Vrana
When I ran build for profiling, it was working, but with classic build there were mentioned errors. After searching through logs it seems there is some weird behaviour with flags, particularly -fprofile-instr-generate. The solution was to set flag Enable Code Coverage to No in build settings of the library project. This was shooting into the dark but somehow got it working.
当我运行构建进行分析时,它可以正常工作,但是在经典构建中出现了提到的错误。在搜索日志后,似乎有一些带有标志的奇怪行为,尤其是 -fprofile-instr-generate。解决方案是在库项目的构建设置中将标志启用代码覆盖设置为否。这是在黑暗中拍摄,但不知何故让它起作用。
回答by Wei WANG
Ran into similar problem. Just post it here in case it can help anyone.
遇到类似的问题。只需将其张贴在这里,以防它可以帮助任何人。
Was using class AbcServicefrom a framework (written in Swift 3 and by ourselves) in our app's Objective-c class B. After upgrading from Xcode8/Swift3 to Xcode9/Swift4 it failed to build an archive for the releaseconfig, due to Undefined symbols
error of this class during linking:
在我们的应用程序的 Objective-c 类 B 中使用框架中的类AbcService(用 Swift 3 和我们自己编写)。从 Xcode8/Swift3 升级到 Xcode9/Swift4后,由于Undefined symbols
错误链接期间的此类:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$__TtC15XxxabcServices17AbcService", referenced from:
The weird thing is, it worked fine to archive the debugconfig, and for running in emulator.
奇怪的是,存档调试配置和在模拟器中运行都很好。
Spent almost 1 day to find out the root cause: the Swift class AbcServicein the framework was missing a public
modifier.
花了将近1天的时间才找出根本原因:框架中的Swift类AbcService缺少一个public
修饰符。
回答by PrasannaKumar
Simple trick here: Go -> Go To Folder "/Library/Developer/Xcode" delete Derived data next clean your project then Run .
这里的简单技巧: Go -> Go To Folder "/Library/Developer/Xcode" delete Derived data next clean your project 然后 Run 。
回答by Thomas Krajacic
Since you are using Cocoapods you most likely need to update those.
由于您使用的是 Cocoapods,因此您很可能需要更新它们。
That means you need to do a pod update
on the command line inside your project's directory and then rebuild your project in Xcode.
这意味着您需要pod update
在项目目录中的命令行上执行 a ,然后在 Xcode 中重建您的项目。
In general when using a new major version of Xcode it is necessary to rebuild all components. Your error message is telling you that the object files you already have (the *.o files are basically what the compiler produces out of your source files) are not compatible with newly compiled object files (the linker which is complaining in your case has the purpose of combining or 'linking' together all the object files).
一般来说,当使用新的 Xcode 主要版本时,有必要重建所有组件。您的错误消息告诉您,您已有的目标文件(*.o 文件基本上是编译器从源文件中生成的文件)与新编译的目标文件不兼容(在您的情况下抱怨的链接器具有将所有目标文件组合或“链接”在一起的目的)。
It might sometimes be necessary to clean your derived data (the stuff Xcode caches). You can do this by going to Xcode's Product
menu and while holding down the Option/Alt key, pick the menu item 'clean build folder'.
有时可能需要清理您的派生数据(Xcode 缓存的内容)。您可以通过转到 Xcode 的Product
菜单并在按住 Option/Alt 键的同时选择菜单项“clean build folder”来完成此操作。