ios Apple Mach-O Linker 错误,我不知道该怎么办
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8706348/
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
Apple Mach-O Linker errors and I don't know what to do
提问by Sega dude
I cannot compile my project for the device or simulator anymore. I get 13 Apple Mach-O-Linker errors. It all started after I failed attempt to use sharekit. Here is the log from the error:
我无法再为设备或模拟器编译我的项目。我收到 13 个 Apple Mach-O-Linker 错误。这一切都是在我尝试使用 sharekit 失败后开始的。这是错误的日志:
ld: warning: directory not found for option '-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks'
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_NSURLRequest", referenced from:
objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in main.o
"_objc_msgSendSuper2", referenced from:
-[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileViewController didReceiveMemoryWarning] in Brandsonic_Web_mobileViewController.o
-[Brandsonic_Web_mobileViewController dealloc] in Brandsonic_Web_mobileViewController.o
"_objc_setProperty", referenced from:
-[Brandsonic_Web_mobileAppDelegate setWindow:] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate setViewController:] in Brandsonic_Web_mobileAppDelegate.o
"__objc_empty_vtable", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
_OBJC_CLASS_$_SecondView in SecondView.o
"_objc_msgSend", referenced from:
_main in main.o
-[Brandsonic_Web_mobileAppDelegate application:didFinishLaunchingWithOptions:] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate dealloc] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate GOOGLE] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate YOUTUBE] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileAppDelegate WIKI] in Brandsonic_Web_mobileAppDelegate.o
-[Brandsonic_Web_mobileViewController webView:shouldStartLoadWithRequest:navigationType:] in Brandsonic_Web_mobileViewController.o
...
"__objc_empty_cache", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_CLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
_OBJC_CLASS_$_SecondView in SecondView.o
"_OBJC_CLASS_$_NSObject", referenced from:
_OBJC_CLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
"___CFConstantStringClassReference", referenced from:
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileAppDelegate.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
CFString in Brandsonic_Web_mobileViewController.o
...
"_OBJC_CLASS_$_NSKeyedUnarchiver", referenced from:
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSUserDefaults", referenced from:
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_CLASS_$_NSURL", referenced from:
objc-class-ref in Brandsonic_Web_mobileAppDelegate.o
objc-class-ref in Brandsonic_Web_mobileViewController.o
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_Brandsonic_Web_mobileAppDelegate in Brandsonic_Web_mobileAppDelegate.o
_OBJC_METACLASS_$_Brandsonic_Web_mobileViewController in Brandsonic_Web_mobileViewController.o
_OBJC_METACLASS_$_SecondView in SecondView.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
'
How do I fix this? Please help.
我该如何解决?请帮忙。
回答by crashbus
For every one with an similar error. If that happens you normally can remove the "Path" under Point
对于每一个有类似错误的人。如果发生这种情况,您通常可以删除 Point 下的“Path”
target->Build Settings->Library Search Paths
目标-> 构建设置-> 库搜索路径
回答by Divine_Code
This error can occur when a framework is added to a project more than once.
当一个框架多次添加到项目中时,可能会发生此错误。
- You can fix this by removing the duplicate. To find it, select the framework in the Xcode project navigator and choose Show in Finder. Then clean and build your project.
- 您可以通过删除重复项来解决此问题。要找到它,请在 Xcode 项目导航器中选择框架并选择Show in Finder。然后清理并构建您的项目。
This can also be caused if you're missing framework header files or a reference to them.
如果您缺少框架头文件或对它们的引用,也会导致这种情况。
- In that case, you should trying removing the SDK or framework and adding it again.
- 在这种情况下,您应该尝试删除 SDK 或框架并重新添加。
Good luck.
祝你好运。
回答by Chris Chute
If you installed dependencies using CocoaPods, make sure you open your XCode project by clicking on your .xcworkspace
file, and notthe .xcodeproj
file.
如果您使用的CocoaPods安装的依赖,确保你点击你打开你的XCode项目.xcworkspace
文件,而不是该.xcodeproj
文件。
回答by Kendall Helmstetter Gelner
It seems like the project file may have been corrupted somehow.
似乎项目文件可能已以某种方式损坏。
The most sure way to fix this is to create a new project, and move your files and old info.plist over on top of it.
解决这个问题最可靠的方法是创建一个新项目,然后将您的文件和旧 info.plist 移到它上面。
The next most likely way to fix this is to create a new target in your current project, and see if that will compile (if you have any special flags from the old target you'll want to copy them).
解决此问题的下一个最可能的方法是在当前项目中创建一个新目标,然后查看它是否会编译(如果旧目标中有任何特殊标志,则需要复制它们)。
Also you could try compiling for Release vs. Build and if one of them works look at all of the compiler options and see what is different.
您也可以尝试针对 Release 与 Build 进行编译,如果其中一个有效,请查看所有编译器选项,看看有什么不同。
If you added a header search path for Sharekit, perhaps try clearing out the whole header search path and see if that fixes things. Also make sure your project is still including frameworks that a brand new project includes (UIKit and NSFoundation, possibly others).
如果您为 Sharekit 添加了标题搜索路径,也许可以尝试清除整个标题搜索路径,看看是否能解决问题。还要确保您的项目仍然包含一个全新项目包含的框架(UIKit 和 NSFoundation,可能还有其他)。
回答by Neenu
Add the .m file to compile source page.
添加 .m 文件以编译源页面。
steps:-
脚步:-
- clicking on he project in the navigation menu
- select the target
- select build phases
- Select the + button and add the file in compile sources.
- 单击导航菜单中的项目
- 选择目标
- 选择构建阶段
- 选择 + 按钮并将文件添加到编译源中。
Hope that helps anyone with this problem
希望能帮助任何有这个问题的人
回答by Bastian
The problems are the spaces in your path:
问题是路径中的空格:
xcode uses the following switch for the linker:
xcode 为链接器使用以下开关:
-F/Users/bbrandy95/Documents/Broken Brandsonic Web Projects/Brandsonic Web mobile/../../Downloads/0.2.1gm1/iphoneos4.0/System/Library/Frameworks
and since it is not quoted it won't work. ( It is looking for the folder "/Users/bbrandy95/Documents/Broken"
并且由于它没有被引用,所以它不起作用。(它正在寻找文件夹"/Users/bbrandy95/Documents/Broken"
You should rename the directories, or look through the project settings and add quotes to the directories. (But this might be tricky to find)
您应该重命名目录,或查看项目设置并向目录添加引号。(但这可能很难找到)
回答by Easwaramoorthy K
I too had the same problem with 45 same kind errors, when I add the libxml2.dylib into my project the errors disappeared.
我也有同样的问题,有 45 个相同类型的错误,当我将 libxml2.dylib 添加到我的项目中时,错误消失了。
回答by Gajendra K Chauhan
In some cases your library Search Path is empty.Because there are many Apple-mac-o linker errors.
在某些情况下,您的库搜索路径为空。因为有很多 Apple-mac-o 链接器错误。
See my answer also at.
另请参阅我的回答。
回答by user3032314
I had this issue, now for my circumstances selecting a more recent iOS version as the deployment target rectified this for me. My project was set to deploy to iOS 5 by default and changing this to 7 (the most recent) did the trick.
我遇到了这个问题,现在根据我的情况选择更新的 iOS 版本作为部署目标为我纠正了这个问题。默认情况下,我的项目设置为部署到 iOS 5,将其更改为 7(最新的)即可解决问题。
For anyone new to iOS development this can be done by clicking on your XCode project file in the navigator > deployment info > deployment target and selecting the appropriate version from the drop down menu.
对于 iOS 开发新手,可以通过单击导航器 > 部署信息 > 部署目标中的 XCode 项目文件并从下拉菜单中选择适当的版本来完成此操作。
I'm sceptical that this will solve some of the issues that others are having but there may be a few people out there in the same boat as me.
我怀疑这是否会解决其他人遇到的一些问题,但可能有一些人与我在同一条船上。
回答by user3032314
It's because the project inserted the core data's xcdatamodeld file in compile sources. Select your project -> Build Phases -> Compile Sources and delete projectName.xcdatamodeld file.
And also check if you have imported .m
file instead of .h
file, it also gives the same linker error. Check all the #import codes.
And check if you have added core data frame work in library and imported core data .h
file. Check for creation of NSManagedObject
and import it's file.
Just try it and reply me if still any error.
这是因为项目在编译源中插入了核心数据的 xcdatamodeld 文件。选择您的项目 -> Build Phases -> Compile Sources 并删除 projectName.xcdatamodeld 文件。并检查您是否导入了.m
文件而不是.h
文件,它也会给出相同的链接器错误。检查所有#import 代码。并检查您是否在库中添加了核心数据框工作并导入了核心数据.h
文件。检查创建NSManagedObject
并导入它的文件。尝试一下,如果仍然有任何错误,请回复我。