iOS Unit Test target can't include host app's files that reference frameworks

时间:2016-07-01 17:21:54

标签: ios unit-testing xcode7

Using XCode 7. Have an app that uses a 3rd party framework (old style xxx.framework, not post-iOS8 dynamic frameworks). Host app includes the framework files using the syntax

<MyExternalFrameworkNameHere/SomeFile.h>

and builds fine. I can #include using (quote-style) files from the host app that do not use any external frameworks in the unit test target .m file and the test target builds just fine. However when the test target references a file from the host app that itself includes a 3rd party framework the test target fails to build saying it can't find the header. Example:

Host app header named SomeHeader.h:

#include <UIKit/UIKit.h> // OK
#include <MyExternalFrameworkNameHere/SomeFile.h> // doesn't like this in test target

XCTest target AppTests.m:

#include "SomeHeader.h" //fails saying it cant find MyExternalFrameworkNameHere/SomeFile.h

If the test target directly includes the offending external framework file like this:

#include <SomeFile.h>

It works, but that doesn't help as I need to test the host app code that uses the framework, not the framework itself. What am I doing wrong here? I've tried adding the external framework to the test target's Link with binaries... but that didn't help.

1 个答案:

答案 0 :(得分:0)

发现问题。框架搜索路径有一个拼写错误,并没有设置为与主机应用程序目标相同的单元测试目标值