如何解决 ios7 和 Xcode 5.0.1 中的 Mach-O-Linker 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22032987/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:41:53  来源:igfitidea点击:

How to solve Mach-O-Linker error in ios7 & Xcode 5.0.1

iosiphonexcode

提问by user3222991

I cannot compile my project for the simulator .
I get Apple Mach-O-Linker error.I cant understand how to solve the issues.I am using xcode 5.0.1.
Please help me any body.
Thanks in advance.

我无法为模拟器编译我的项目。
我收到 Apple Mach-O-Linker 错误。我无法理解如何解决这些问题。我使用的是 xcode 5.0.1。
请帮助我任何身体。
提前致谢。

Ld /Users/murthych/Library/Developer/Xcode/DerivedData/ClassifiedDetails-elseirogpshyhmffphsiejgydphd/Build/Products/Debug-iphonesimulator/ClassifiedDetails.app/ClassifiedDetails normal i386
    cd /Users/murthych/Desktop/ClassifiedDetails
    setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/murthych/Library/Developer/Xcode/DerivedData/ClassifiedDetails-elseirogpshyhmffphsiejgydphd/Build/Products/Debug-iphonesimulator -F/Users/murthych/Library/Developer/Xcode/DerivedData/ClassifiedDetails-elseirogpshyhmffphsiejgydphd/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/murthych/Library/Developer/Xcode/DerivedData/ClassifiedDetails-elseirogpshyhmffphsiejgydphd/Build/Intermediates/ClassifiedDetails.build/Debug-iphonesimulator/ClassifiedDetails.build/Objects-normal/i386/ClassifiedDetails.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework XCTest -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/murthych/Library/Developer/Xcode/DerivedData/ClassifiedDetails-elseirogpshyhmffphsiejgydphd/Build/Intermediates/ClassifiedDetails.build/Debug-iphonesimulator/ClassifiedDetails.build/Objects-normal/i386/ClassifiedDetails_dependency_info.dat -o /Users/murthych/Library/Developer/Xcode/DerivedData/ClassifiedDetails-elseirogpshyhmffphsiejgydphd/Build/Products/Debug-iphonesimulator/ClassifiedDetails.app/ClassifiedDetails

Mach-O-Linker error message

Mach-O-Linker 错误消息

building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/??XCTest' for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) "

回答by Amar

XCTest.frameworkneeds to be linked only to the unit test target in your project. It should not be added to the UI application target.

XCTest.framework只需要链接到项目中的单元测试目标。不应将其添加到 UI 应用程序目标。

What I have found is when adding XCTest.frameworkXcode adds extra \to Framework Search Paths

我发现添加XCTest.frameworkXcode 时会增加额外\的内容Framework Search Paths

\"$(SDKROOT)/Developer/Library/Frameworks\"
\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"
$(DEVELOPER_FRAMEWORKS_DIR)

enter image description here

在此处输入图片说明

This causes linker issue,

这会导致链接器问题,

ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To resolve this issue in XCode 5.1 goto the main ProjectWindow, Tab Build Settings-> Section Search Path-> Framework Search Pathsand edit to remove \appearing the paths.

要在 XCode 5.1 中解决此问题,请转到主 ProjectWindow,Tab Build Settings-> Section Search Path-> Framework Search Paths并编辑以删除\出现的路径。

Hope that helps!

希望有帮助!

回答by MacMark

Deleting the test target and creating a new one and then copying the tests over can fix this.

删除测试目标并创建一个新目标,然后复制测试可以解决这个问题。

If you down vote this please provide a valid reason because this hint worked for me.

如果您对此投反对票,请提供有效理由,因为此提示对我有用。

回答by Irfan

I suggest you to use xcode 5.02 stable version and then hopefully these Mac-O Linker errors will be resolved.same problems I am facing too before installing xcode 5.02.

我建议您使用 xcode 5.02 稳定版本,然后希望这些 Mac-O 链接器错误将得到解决。在安装 xcode 5.02 之前我也面临同样的问题。