简体   繁体   中英

OCUnit tests to existing iOS project. “ld: file not found”

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

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.

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.

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

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.

我之前遇到了同样的问题,我通过检查单元测试目标的Build Settings - > Base SDK来解决这个问题,并根据你的项目类型(OSX或iOS)确保它是正确的。

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

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM