OCUnit tests to existing iOS project. "ld: file not found"
Asked Answered
W

6

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

Wallaroo answered 5/3, 2012 at 22:59 Comment(1)
Maybe you have a case sensitive file system and have the wrong case on a letter? I've seen that one before.Nodababus
K
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.

Keeler answered 9/3, 2012 at 1:50 Comment(3)
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.)Anjanette
I had the same problem and this solved. The problem is that I had renamed the main target, and then Xcode got lost.Chiasma
Cleaning or deleting derived data did nothing. I re-named my targets Product Name to what it should have been and its working. thanks!Polymer
E
5

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.

Erbil answered 30/8, 2012 at 22:55 Comment(4)
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?Enkindle
On a similar note, don't put double quotes around this either, even if you have spaces in your app's name.Kinsella
To be clear, don't put any quotes around this. Neither double nor single quotes worked for me, but no quotes DID work.Lamination
I had a newline from a copy paste. Yikes! This was insanely helpful though, so thanks!Sounding
H
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

Harijan answered 17/12, 2013 at 8:3 Comment(0)
S
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.

Spanos answered 4/4, 2014 at 12:43 Comment(0)
L
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).

Leeland answered 31/10, 2014 at 4:34 Comment(0)
H
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

Honour answered 6/6, 2016 at 16:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.