ios Apple Mach-O 链接器 (Id) 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6769008/
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 (Id) error
提问by C.Johns
Got this error for the first time, I have looked around and cannot find a solution to help me, I have cleaned my build and also checked to make sure I am compiling for the latest firmware.
第一次遇到这个错误,我环顾四周,找不到可以帮助我的解决方案,我已经清理了我的构建并检查以确保我正在编译最新的固件。
This happened after I tired implementing a reachability solution I found over hereI imported the two reachability files (.m/.h) then added this code into the .m file and delared t in the . h of the reachability files
这是在我厌倦了实现可达性解决方案之后发生的,我在这里找到了 我导入了两个可达性文件 (.m/.h),然后将此代码添加到 .m 文件中并在 . h 可达性文件
-(BOOL)reachable {
Reachability*r =[Reachability reachabilityWithHostName:@"enbr.co.cc"];
NetworkStatus internetStatus =[r currentReachabilityStatus];
if(internetStatus ==NotReachable){
return NO;
}
return YES;}
After that I called the function from both of my viwcontrollers viewwillappear methods like so..
之后,我从我的两个 viwcontrollers viewwillappear 方法中调用了该函数,就像这样..
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//-- Check Reachability START ---->
Reachability *reach = [[Reachability alloc] init];
if ([reach reachable]) {
NSLog(@"Reachable");
}
else {
NSLog(@"Not Reachable");
}
//-- Check Reachability END ---->
}
No errors were produced untill I tried to build and run in the simulator. This is the error I received :(
在我尝试在模拟器中构建和运行之前,没有产生任何错误。这是我收到的错误:(
Ld /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator/wizcode.app/wizcode normal i386 cd "/Users/imac/Documents/Iphone applications/wizsanCode/wizsanCode.5/wizcode" setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator -F/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator -filelist /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/wizcode.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -lz -framework CoreGraphics -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework UIKit -framework Foundation -o /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator/wizcode.app/wizcode
ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o and /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o for architecture i386 collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1 ld: duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o and /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o for architecture i386
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
ld /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator/wizcode.app/wizcode normal i386 cd "/Users/imac/Documents/Iphone applications/wizCodesanCode5/wizsan /wizcode" setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/imac/ Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator -F/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Products/Debug-iphonesimulator imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/wizcode.LinkFileList -mmacosx-version-min=10。6 -Xlinker -objc_abi_version -Xlinker 2 -lz -framework CoreGraphics -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework UIKit -framework Foundation -o /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbBuild /Debug-iphonesimulator/wizcode.app/wizcode
ld: 重复符号 _OBJC_IVAR_$_Reachability.reachabilityRef 在 /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.build/Objectsability-normal -183E2D17A6B26176.o 和/Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode.build/Debug-iphonesimulator/wizcode.each/Objects-normal/i2616E3816A架构 i386 collect2:ld 返回 1 退出状态命令 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 失败,退出代码 1 ld:重复符号 _OBJC_IVAR_$_Reachability.reachabilityRef in /Users/imac/库/开发人员/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Intermediates/wizcode。build/Debug-iphonesimulator/wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o 和 /Users/imac/Library/Developer/Xcode/DerivedData/wizcode-ccyrqptvfsabmbahgxartbvxwurq/Build/Debug-codesimulator/ /wizcode.build/Objects-normal/i386/Reachability-183E2D17A6B26176.o 架构 i386
命令 /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 失败,退出代码为 1
采纳答案by C.Johns
So, the problem has been resolved.
所以,问题已经解决了。
What happened was when I imported the reachability files over into my build something funny was happening and somehow I deleted the reachability files that were already in my build being used by the "all seeing I" ASIHTTPRequest methods I was using for transporting my data... which messed everything up.
发生的事情是,当我将可达性文件导入到我的构建中时,发生了一些有趣的事情,不知何故,我删除了我的构建中已经存在的可达性文件,这些文件被我用来传输数据的“所有看到我”ASIHTTPRequest 方法所使用。 . 这把一切都搞砸了。
So long story short I replaced the files and everything is working fine and I also found out that ASIHTTPTequest is taking care of the reachability for me :) how cool is that.
长话短说,我替换了文件,一切正常,我还发现 ASIHTTPTequest 正在为我处理可达性:) 这有多酷。
回答by Anton
Check if SystemConfiguration
is linked properly. Anyway, clean up your code:
检查是否SystemConfiguration
正确链接。无论如何,清理你的代码:
+ (BOOL)reachable {
Reachability *r = [Reachability reachabilityWithHostName:@"enbr.co.cc"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
return internetStatus != NotReachable;
}
And then just call [Reachability reachable]
wherever you need. This also fixes a memory leak you have.
然后只需[Reachability reachable]
在您需要的任何地方拨打电话。这也修复了您的内存泄漏。
回答by Alan
Just to add to this, it happened me after I regenerated managed subclasses and it didn't actually overwrite the existing ones but just made new duplicates. I just deleted both and regenerated and it was all good.
只是为了补充一点,在我重新生成托管子类之后发生了这种情况,它实际上并没有覆盖现有的子类,而是创建了新的副本。我刚刚删除了两个并重新生成,一切都很好。
回答by Alan
Remove it then add it again. Works for me. :D
删除它然后再次添加它。为我工作。:D
回答by Gaurav
This happens with me when i am adding third party analytics framework in my project. When i check with the info of framework its not properly copied on disk. i download new framework and copied it into project and now there is no error.
当我在我的项目中添加第三方分析框架时,就会发生这种情况。当我检查框架的信息时,它没有正确复制到磁盘上。我下载了新框架并将其复制到项目中,现在没有错误。
回答by coolcool1994
I had this code in one of my UIViewController and removing it solved this bug. What a stupid and not-clear-at-all error message
我在我的 UIViewController 之一中有此代码并删除它解决了这个错误。多么愚蠢且根本不明确的错误消息
NS_ENUM(NSInteger, Mode) {
Assessments = 0,
Onboarding
};
回答by Alexander
Make sure you are running YourApp.xcworkspace instead of .xcodeproj file. I did face the same issue when did run .xcodeproj file. Running .xcworkspace has solved the problem and the error has gone away.
确保您正在运行 YourApp.xcworkspace 而不是 .xcodeproj 文件。运行 .xcodeproj 文件时,我确实遇到了同样的问题。运行 .xcworkspace 已经解决了问题,错误也消失了。
回答by James LeMay
After modifying my core data model, I deleted all the (auto generated) NSManagedObjectModel subclasses, and created them again. Once they all were created, I dragged them to a Group folder in XCode... and got the spinning beachball for longer than usual.
修改我的核心数据模型后,我删除了所有(自动生成的) NSManagedObjectModel 子类,并再次创建它们。一旦它们全部创建完毕,我将它们拖到 XCode 中的一个 Group 文件夹中......并获得比平时更长的旋转沙滩球。
The next time I tried to run, it failed with the "Mach-O-Linker" (Id) Error. After reading other responses, I figured it might have something to do with the NSMObj classes not being where expected. I deleted them, quit, opened, generated them, and put them in their customary group folder... and Viola! no Mach-O error.
下次我尝试运行时,它因“Mach-O-Linker”(Id)错误而失败。阅读其他回复后,我认为这可能与 NSMObj 类不在预期的地方有关。我删除了它们,退出,打开,生成它们,并将它们放在他们习惯的组文件夹中......还有 Viola!没有 Mach-O 错误。
I see that the problem is resolved, but I post this just to index it under the proper question. In my case, deleting and regenerating (via editor menu) the managed object subclasses fixed the issue.
我看到问题已解决,但我发布此信息只是为了将其索引到正确的问题下。就我而言,删除和重新生成(通过编辑器菜单)托管对象子类解决了该问题。