iphone - Apple Mach-O 链接器 (Id) 错误

标签 iphone ios linker mach-o

第一次遇到这个错误,我环顾四周,找不到可以帮助我的解决方案,我已经清理了我的构建并检查以确保我正在编译最新的固件。

这发生在我厌倦了实现我在 here 上找到的可达性解决方案之后 我导入了两个可达性文件 (.m/.h),然后将这段代码添加到 .m 文件中,并在 .m 文件中删除了 t。 h 的可达性文件

-(BOOL)reachable {
    Reachability*r =[Reachability reachabilityWithHostName:@"enbr.co.cc"];
    NetworkStatus internetStatus =[r currentReachabilityStatus];
    if(internetStatus ==NotReachable){
        return NO;
    }
    return YES;}

之后,我从我的两个 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 ---->
}

在我尝试在模拟器中构建和运行之前没有产生任何错误。这是我收到的错误:(

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

最佳答案

那么,问题就解决了。

发生的事情是,当我将可达性文件导入到我的构建中时,发生了一些有趣的事情,并且我以某种方式删除了我的构建中已经存在的可达性文件,这些文件被我用来传输我的“全视我”的 ASIHTTPRequest 方法使用数据……把一切都搞砸了。

长话短说,我替换了文件,一切正常,我还发现 ASIHTTPTequest 正在为我处理可达性:)这有多酷。

关于iphone - Apple Mach-O 链接器 (Id) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6769008/

相关文章:

c - 链接器在节中添加额外的填充?

iphone - 我可以在 iPhone 上使用 setModalPresentationStyle 吗?

iphone - 在iPhone中使用3G来电的Pjsip在UDP中时没有音频

ios - 为什么 Objective-C API 会返回隐式解包的可选值?

ios - 如何在 iOS 中发送对象作为 POST 请求的参数?

linux - 如何在编译/链接时让 gcc 达到每个内核不超过 50% 的占用率?

ios - 链接错误 Xcode 7.2 : Framework Not Found

objective-c - iphone 中的文本下划线

iphone - 不正确的签名错误

ios - 滑动式护腕 iOS