Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

iphone

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.

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

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) "
like image 852
user3222991 Avatar asked Feb 26 '14 05:02

user3222991


2 Answers

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.

like image 25
MacMark Avatar answered Sep 18 '22 00:09

MacMark


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

What I have found is when adding XCTest.framework Xcode adds extra \ to 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 Paths and edit to remove \ appearing the paths.

Hope that helps!

like image 74
Amar Avatar answered Sep 18 '22 00:09

Amar