18

I've been following this blog post: Adding unit tests to existing project.

I'm getting this error however:

ld: file not found: Build/Products/Debug-iphoneos/MyApp.app/MyApp Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1

I have my test target properties,

Bundle Loader = $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp

Test Host = $(BUNDLE_LOADER)

(which both equate to: build/Debug-iphoneos/MyApp.app/MyApp)

My wild guess is that those variables aren't pointing to the same location as the compiler. "build/Debug-iphoneos/..." vs "Build/Products/Debug-iphoneos/..."

I could be totally wrong on that guess, but either way, does anyone know what's causing this error or how I would fix those environment variables?

Thanks for any help,

Sam

Sam
  • 1,042
  • 2
  • 8
  • 19
  • 1
    Maybe you have a case sensitive file system and have the wrong case on a letter? I've seen that one before. – fisk Mar 05 '12 at 23:46

6 Answers6

18

Dig into ~/Library/Developer/Xcode/DerivedData, down into your project. From there, follow the Bundle Loader path. See what's actually there.

Now look at your Info.plist (or your target's Info settings) and look for "Executable file" or CFBundleExecutable. If it's ${EXECUTABLE_NAME}, check your target's "Product name" setting.

Jon Reid
  • 20,545
  • 2
  • 64
  • 95
  • 5
    Another thing to check is the `Bundle Loader` settings for your unit test target. That had the path to the app executable mostly hardcoded from when the Xcode 4 project was created. (I had since changed the product name in the app target and the unit test target had no idea about it.) – zekel Apr 03 '12 at 15:39
  • I had the same problem and this solved. The problem is that I had renamed the main target, and then Xcode got lost. – Giovanni Sep 20 '12 at 00:26
  • Cleaning or deleting derived data did nothing. I re-named my targets Product Name to what it should have been and its working. thanks! – RyanG Nov 17 '14 at 14:37
6

I ran into the same problem - it didn't make sense as the path it was using to the executable actually existed. Taking a close look at the compile command revealed that there was an extra space on the loader path that was the problem.

Steve Dekorte
  • 219
  • 3
  • 2
  • 5
    Thanks! Finding this has just saved me some time. Was driving me nuts -- the was getting a file not found repeatedly on a bundle loader that clearly did exist. In the build settings editor, `$(BUILT_PRODUCTS_DIR)/FSMTest.app/FSMTest` is not the same as ` $(BUILT_PRODUCTS_DIR)/FSMTest.app/FSMTest` (ie. with a prepended space). Could Apple not have designed the settings editor dialogue with a modicum of checking? – Cris Sep 14 '12 at 23:07
  • 1
    On a similar note, don't put double quotes around this either, even if you have spaces in your app's name. – Daniel Thorpe Apr 28 '13 at 16:52
  • 1
    To be clear, don't put *any* quotes around this. Neither double nor single quotes worked for me, but no quotes DID work. – Robert Atkins May 13 '13 at 09:08
  • 1
    I had a newline from a copy paste. Yikes! This was insanely helpful though, so thanks! – Ben Flynn Oct 31 '13 at 23:36
0

Looking for "Search Paths" inside Build Settings. Probably there are unexistent paths under "Framework Search Paths" or the others paths like Library Search Paths

Alessandro Ornano
  • 34,887
  • 11
  • 106
  • 133
0

There is a possibility that you changed the name of the application after creating your project. So the name of your project and application are different. In the path, use your application name as it would appear on itunes store instead of your project name.

Khawar Ali
  • 3,462
  • 4
  • 27
  • 55
0

I had the same problem earlier and I resolved this by checking the Build Settings -> Base SDK of my unit test target, and make sure it's correct based on your project type (OSX or iOS).

tropicalfish
  • 1,230
  • 1
  • 16
  • 29
0

In your podfile make sure that you have included your tests as a target

target 'YourAppNameTests' do use_frameworks! pod 'AFNetworking', '2.6.0' pod 'TYMProgressBarView' end

This will automatically add Link Binary with Libraries Framework

enter image description here

HannahCarney
  • 3,441
  • 2
  • 26
  • 32