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

蓝咒 提交于 2019-12-03 11:19:15

问题


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


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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.




回答5:


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).




回答6:


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



来源:https://stackoverflow.com/questions/9575390/ocunit-tests-to-existing-ios-project-ld-file-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!