开发者

Do I have to do something to get OCunit tests to compile out of box with XCode 4?

开发者 https://www.devze.com 2023-02-16 17:01 出处:网络
I just installed XCode 4 today (using Apple mac app store), and I created a new Mac OS application, and tried to switch to test mode,and build the test skeleton code it generated for me. It failed her

I just installed XCode 4 today (using Apple mac app store), and I created a new Mac OS application, and tried to switch to test mode,and build the test skeleton code it generated for me. It failed here:

In mytests.h:

#import <SenTestingKit/SenTestingKit.h>

The error is:

file://..mytests.h: error: Lexical or Preprocessor Issue: 'SenTestingKit/SenTestingKit.h' file not found

Now, when I use locate from the terminal to find SenTestingKit.h, I notice it exists under the /Developer-old/Library/Frameworks folder (which is what XCode 开发者_StackOverflow4 installer renamed my /Developer folder to). There is no new /Developer/Library/Frameworks. And I can't seem to find SenTestingKit.framework on my disk, other than the developer-old one.

What's up? It seems SenTestingKit.framework is not shipped with XCode 4.

Update:

Furthermore, When I copy my old SenTestingKit framework from XCode 3 into /Developer/Library/Frameworks, it sort of builds, but it doesn't work the way I would expect. The dummy test is designed to just fail, but when I "run test", I just get the normal cocoa app document window opening, and no indication that my test has failed (as I intend it to do).

This is pretty bad. I can't get a Unit test to FAIL. That's not the usual situation for me, you understand.


You may find that the reason for this is because you've installed Xcode 4 into a directory such as /Xcode 4.x/ or similar. The space is causing the problem because the -I paths are "Xcode" and "4.x/Library/Frameworks".

To fix this, what you need to do is select your test target, and under its build settings go and find the Framework Search Path, and put quotes around the two arguments, so you have:

"$(SDKROOT)/Developer/Library/Frameworks" and "$(DEVELOPER_LIBRARY_DIR)/Frameworks"

Then you default tests will compile, link and fail.


You will maybe need to import the framework into your project. Otherwise, the header file won't be recognize.

If you can't see the framework you're looking for, you can adjust the framework look paths in your project's build settings.


When you're building unit tests in the same project as you main code, make sure that XCode 4 didn't automatically connect you mytests.m file into the "Compile Sources" section of your main code.

For example, if you have two targets in our project:

MyProject

MyProjectTests

Check the Build Phases for MyProject to see if XCode added mytests.m into the "Compile Sources" accordion. This will cause your builds to fail because SenTest isn't included in the main project.

0

精彩评论

暂无评论...
验证码 换一张
取 消