62
votes

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
11
Are you using any third-party frameworks?Morgan Chen
It looks like you've made a mistake adding the Facebook SDK to your project.Morgan Chen

11 Answers

219
votes

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.

29
votes

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
15
votes

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

13
votes

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.

4
votes

Did you try cleaning up your derived data?

Xcode5->Organizer->Projects->Select your project->Delete the derived data.
2
votes

Try to remove "Social_EventsTests" target.

2
votes
  1. Goto Build settings of your tests named PuzzleGameTests.
  2. Go to Testing settings, write $(BUILT_PRODUCTS_DIR)/PuzzleGame.app/PuzzleGame
  3. Clean and build

Note: PuzzleGame is new name of my project(product name). RandomNumber is old name of my project(product name).

2
votes

I had issue with "framework not found". It was after renaming my project.

Go to Project settings, select the target (not the project). In the General tab, find "Linked frameworks and libraries", and delete the old name.

0
votes

I encountered similar problem while adding FBSDKCoreKit.framework and solution was :

  1. If frameworks already added then remove it with option remove all references.
  2. Drag & drop frameworks straight in the group you want it to put in project.
  3. do not re-drag or change its location afterwords

Note: When we drag & drop frameworks in xcode it automatically set framework search path under <yourproject> -> Targets -> <yourproject> -> Search Paths -> Framework Search Paths . once we relocate the frameworks, the Framework Search Paths becomes empty and it results in linker error , framework not found.

0
votes

Had similar kind of problem when I added unit test target to my existing project. Got all sorts of error. Had to run through some loops to get it finally running. Listing them below

  1. Make sure your entry under Header search path for test target matches that for Header Search Path in your main project folder

  2. If you are using pods you might run in some error such 'No Module found Firebase'. For this simply add the following lines of code to your pod file and run pod install

    target 'YourProjectNameTests' do

    inherit! :search_paths

    # Pods for testing

    end

  3. If you also get Bridging header file not found error like I did make sure you add the same for your test target in Build settings under Swift compile code general

  4. Also you will have to follow the steps mentioned by @Jose Llausas

0
votes

I had similar kind of problem when I added a framework to my project.

I have resolved the issue by removing the framework and again adding the framework to the project by dragging and dropping the framework file to the projects frameworks folder and selecting the Copy items if needed option.

enter image description here