ld: file not found: linker command failed with exit code 1

46,017

Solution 1

You might be getting this error because you renamed your project and Tests cannot be found anymore. This is easy to fix:

Solve it in Xcode like this:

  1. Select your project from the project navigator.
  2. Select [Your project's Tests] under targets
  3. Under General tab change the Host Application from the drop down
  4. Build and run.

Screenshot

This problem happened to me because I renamed my project and the tests could't find it anymore.

Solution 2

The problem is that after renaming the product its Tests target is still looking for the previous app name.

Select your Tests target and then in Build Settings modify the TestHost values to correspond your new product name in the following way:

$(BUILT_PRODUCTS_DIR)/YourNewProductName.app/YourNewProductName

Solution 3

I had a similar problem -- it's because I was using Cocoapods and had opened the .xcodeproj file instead of the .xcworkspace file... doh!

Solution 4

I have solved it by renaming the product.

In the Application's target choose Build Settings.

Under the Packaging options, you have to rename your product to the name thats shown in the error.

It solved my problem and the code started compiling. My test cases are also executing.

Solution 5

Did you try cleaning up your derived data?

Xcode5->Organizer->Projects->Select your project->Delete the derived data.
Share:
46,017
Admin
Author by

Admin

Updated on July 19, 2020

Comments

  • Admin
    Admin almost 4 years

    I've got the following error when building the project in Xcode:

    ld: file not found

    /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I'm stuck with this error for the past hour.. Any solutions? Code worked fine in iOS 7 and xCode 5.0. Now for iOS8 it gives me this error.

    Using frameworks:

    • CoreTelephony
    • Mapkit
    • Facebook.SDK v3.20
    • Foundation
    • CoreGraphics
    • UIKit Framework

    FULL ERROR:

    <pre>
    Ld /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests normal arm64
        cd /Users/MacBookPro/Desktop/Social_Events/Social_Events/Social_Events
        export IPHONEOS_DEPLOYMENT_TARGET=7.1
        export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    </pre>
    
    >/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -L/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos -F/Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/Developer/Library/Frameworks -filelist /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests.LinkFileList -dead_strip -bundle_loader /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events -framework XCTest -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.1 -framework XCTest -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests_dependency_info.dat -o /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Intermediates/Social_Events.build/Debug-iphoneos/Social_EventsTests.build/Objects-normal/arm64/Social_EventsTests
    
    >ld: file not found: /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    >(null): File not found: /Users/MacBookPro/Library/Developer/Xcode/DerivedData/Social_Events-cfnteabiivwfdzcoulzznhmgobhy/Build/Products/Debug-iphoneos/Social_Events.app/Social_Events