“File not found”, “linker command failed with exit code 1” in Xcode 4.5.1

28,917

Solution 1

Steps to resolve:

  1. Create new scheme with different name
  2. Delete old scheme

  3. Add new scheme

Where the problem came from:

I changed my product name and disabled the snapshot option. Then, suddenly, this error popped out:

ld: file not found:.././previousproductname.app/previousproductname

Steps I followed unsuccessfully to debug:

  1. Deleted deriveddata, restarted Xcode. - not resolved.

  2. Followed the steps of this: link http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ - same error; not resolved.

  3. Finally, I changed the Scheme name, deleted my old scheme and added new, have solved my issue.

Solution 2

I encountered the same error message. Turned out I had renamed my app target and had not updated the test target, Build Settings, Bundle Loader setting to my new app name.

More details on this setting can be found at Adding Unit Tests to an existing iOS project with Xcode 4 I reviewed the same steps and it helped me fix my project in Xcode 5.

Solution 3

You must have changed your product name. Due to mis-match of your workspace name and product(application)name this error occurs.

You just need to replace the workspace name to product(application) name in the TEST HOST Build settings of the ProjectName-Tests targe as stated in the image. To catch up that, select to ProjectName-Tests target, select Build Settings, search for the Test Host term.

enter image description here

This is the standard configuration solution for this error.

Cheers!!

Solution 4

Delete your scheme then re-create it (click new icon or using autocreate of xcode). It works for me.

Solution 5

On xcode 6 you need to:

  1. go to products folder
  2. click on file .xctext
  3. on "TARGETS" choose Tests
  4. and on Host Application choose your application.
  5. Click build app.

Works for me!

Share:
28,917
Yuvaraj.M
Author by

Yuvaraj.M

iOS developer.

Updated on April 23, 2020

Comments

  • Yuvaraj.M
    Yuvaraj.M about 4 years

    Am developing an existing iOS application and I have to write unit test cases for this project. It is building and running in Simulator 6.0. Whenever I try to test the project, it is showing the error message below. Am not able to figure the exact error.

    id: file not found: /Users/Yuva/Library/Developer/Xcode/DerivedData/FlyApp-aexukpgtbathuadgxlnm/Build/Products/Debug-iphonesimulator/FlyApp.app/FlyApp
    clag: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Could you please help me to solve this linker error and test the app?

  • Yuvaraj.M
    Yuvaraj.M about 11 years
    Hi. Am not able to see /Users/Yuva/Library/ because inside of Yuva folder the Library is missed. What shoul i do to get resolve this issue? Can you plesae help me? thanks.
  • Owen Hartnett
    Owen Hartnett about 11 years
    For some reason, the code you wrote thinks that there is a file there. I know that sometimes the DerivedData folders get messed up, and perhaps looking at Xcode's Preferences->Locations menu item might clear it up.
  • Yuvaraj.M
    Yuvaraj.M about 11 years
    Thank you for your reply. Now I got the Derived Data folder followed by your guide. There are many folders with Build, Index, info.plist, Logs, scm.plist and TextInex. May i deleted the DerivedData folder items? Please help me. Thanks.
  • Yuvaraj.M
    Yuvaraj.M about 11 years
    I tried to delete all the items in DerivedData folder and restarted the Mac. Again when I tried to "Test" the app it is showing the same error. I don't have idea to resolve this issue. Could you please help me? Thanks.
  • Albert Renshaw
    Albert Renshaw almost 10 years
    It's not that the library folder is missing, it's that it's hidden... you have to turn on view hidden files in finder through terminal.
  • Albert Renshaw
    Albert Renshaw almost 10 years
    And the in finder select "view file path" or "path bar" or something, then select hidden folder "library" then on the bottom path bar double click on "*~ --> Library"
  • derpoliuk
    derpoliuk over 9 years
    I had this issue after renaming. Changing Bundle Loader in Test Target Build Settings helped me fix it.
  • arnold
    arnold over 9 years
    this works for me, my god ive been banging my head just to fix it, Thanks
  • Aron Lorincz
    Aron Lorincz over 9 years
    Same here: someone renamed the app, and the linker was still looking for the old one.
  • user1154390
    user1154390 over 9 years
    I had same problem - Create a new scheme works for me. Steps in XCode 6 Go to PRODUCTS TAB then go to SCHEME and then go to MANAGE SCHEME PRESS Minus sign and then + to create new scheme.
  • Josh
    Josh over 9 years
    This worked for me. For newbies like myself do persist in finding the "test target" from the "project settings". You will see immediately the erroneous "bundle loader" paths in the "linking" section, but this was not the source of my error as these entries refer to a "$(TEST_HOST)". Scroll down to the "testing" section and fix the "test host" entries and this will update the linking section.
  • Nikhil Lihla
    Nikhil Lihla over 9 years
    @haotang you are a life saver... Thankyou very much... i have tried so many solutions but nothing worked except this... Ty :)
  • SmileBot
    SmileBot over 9 years
    Creating a new scheme did it for me. In my case I pulled down my project to a new machine from bitbucket.
  • user3204765
    user3204765 about 9 years
    This works for me too. Wonder why there isn't simple way to delete the DerivedData and re-create them.
  • Daniel Shin
    Daniel Shin about 9 years
    You saved my day! Creating a new scheme indeed works! I love SO so much.
  • Mihir Mehta
    Mihir Mehta about 9 years
    FYI ... It's available in your Test Target's build setting under Linking section (Xcode 6.3.2)
  • Kuldeep
    Kuldeep almost 9 years
    Always my pleasure @ThomásC. :)
  • Bruce
    Bruce almost 9 years
    This is it.. happened to me when I add a space in the Product name. Remember to you must change not only one name but two in the same path, e.g. from FlyApp.app/FlyApp to abcd.app/abcd
  • Joakim M
    Joakim M almost 9 years
    King! New Scheme = Work!
  • Crashalot
    Crashalot almost 9 years
    Only worked for us by clicking "plus" icon, not by using autocreate.
  • Viktor Nilsson
    Viktor Nilsson almost 9 years
    The old Scheme for me too that was the problem. Removing it and creating a new one resolved the problems for me as well. Thanks!
  • loomer
    loomer almost 8 years
    Updating the Test Host fixed this issue for me.
  • JastinBall
    JastinBall over 7 years
    Perfect solution!
  • FortuneCookie
    FortuneCookie over 4 years
    its about XCode 4.5!
  • shyam_ssr
    shyam_ssr over 4 years
    it is to help someone who lands in this page with recent xcode's.
  • cherucole
    cherucole over 4 years
    Such a life saver. Ran into the problem while building a react native app too, had to just create a new scheme in 'manage schemes'. Created a new scheme and unchecked the old one then it worked