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

IosObjective CXcodeLinker

Ios Problem Overview


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

Ios Solutions


Solution 1 - Ios

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 - Ios

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 - Ios

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 - Ios

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 - Ios

Did you try cleaning up your derived data?

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

Solution 6 - Ios

Try to remove "Social_EventsTests" target.

Solution 7 - Ios

  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).

Solution 8 - Ios

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.

Solution 9 - Ios

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.

Solution 10 - Ios

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

  1. 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

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

Solution 11 - Ios

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser4200570View Question on Stackoverflow
Solution 1 - IosJose LlausasView Answer on Stackoverflow
Solution 2 - IosVladimir AfinelloView Answer on Stackoverflow
Solution 3 - IosDarrenView Answer on Stackoverflow
Solution 4 - IosSelvinView Answer on Stackoverflow
Solution 5 - IosthatzpremView Answer on Stackoverflow
Solution 6 - IosvahotmView Answer on Stackoverflow
Solution 7 - Iospkc456View Answer on Stackoverflow
Solution 8 - IosVlad PulichevView Answer on Stackoverflow
Solution 9 - IosDashrathView Answer on Stackoverflow
Solution 10 - IosSaketGupteView Answer on Stackoverflow
Solution 11 - IosRenjithnath RamachandranView Answer on Stackoverflow