36

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?

10 Answers 10

90

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.

0
35

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.

2
  • 1
    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.
    – Josh
    Jan 3, 2015 at 13:28
  • 2
    FYI ... It's available in your Test Target's build setting under Linking section (Xcode 6.3.2) Jun 23, 2015 at 6:40
21

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

4
  • Always my pleasure @ThomásC. :)
    – Kuldeep
    Jul 15, 2015 at 6:57
  • 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
    – Bruce
    Jul 18, 2015 at 8:17
  • Updating the Test Host fixed this issue for me.
    – loomer
    Aug 10, 2016 at 9:34
  • 1
    Perfect solution!
    – JastinBall
    Oct 22, 2016 at 21:15
18

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

3
  • this works for me, my god ive been banging my head just to fix it, Thanks
    – nold
    Nov 12, 2014 at 16:24
  • @haotang you are a life saver... Thankyou very much... i have tried so many solutions but nothing worked except this... Ty :) Jan 12, 2015 at 9:39
  • Only worked for us by clicking "plus" icon, not by using autocreate.
    – Crashalot
    Aug 9, 2015 at 6:33
6

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!

1

ARGH! This is a terribly frustrating issue that came out of the blue from my XCode 8.2

In my case it came down to removing my Tests target from the scheme, building and running the main app, then readding the Tests target to the 'Test' section.

It appears that the Tests target was trying to find something it wanted in the Derived Data which wasn't built yet. Running the app without trying to build tests too allowed the previously missing derived data to be prepared.

...Insanity is doing the same thing in XCode twice and expecting the same result :|

0

Your linker is looking for a file at: /Users/Yuva/Library/Developer/Xcode/DerivedData/FlyApp-aexukpgtbathuadgxlnm/Build/Products/Debug-iphonesimulator/FlyApp.app/FlyApp

Did you follow the path to ascertain if the file is there? Note that FlyApp.app is probably a package and you'll have to "see package contents" if you're viewing from the Finder. If it's not there, either 1) you need to build FlyApp.app first, or 2) you have something in your test code that depends on it being there, which can't be determined from your question.

6
  • 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.
    – Yuvaraj.M
    Apr 17, 2013 at 10:51
  • 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. Apr 17, 2013 at 15:20
  • 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
    Apr 22, 2013 at 8:17
  • 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.
    – Yuvaraj.M
    Apr 22, 2013 at 9:20
  • 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. Sep 7, 2014 at 1:29
0

The answer lies on your Build Settings > Library Search Paths entry. Make sure there are no fully qualified paths listed there. Decorate them with the $SRCROOT idiom and enclose the path with double quotes. If there are any escape backslashes make sure to remove them as well.

Do a Clean and then Build and you should be back in business. This seem to be an issue with Xcode 5.x

0

Create a new scheme. The bundle id / target name / executable / project name etc. are all slightly different concepts. If you change one (as I did) the old scheme may still be set to look for the old value as the name of the executable, while the build process may have been updated to no longer build that executable.

-2

In Xcode 11 select Product -> Scheme -> new Scheme

this worked for me. Image

2
  • its about XCode 4.5! Dec 11, 2019 at 11:25
  • it is to help someone who lands in this page with recent xcode's.
    – shyam_ssr
    Dec 11, 2019 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.