简体   繁体   中英

Referencing Classes from Different Targets in xCode for iPhone Unit Testing

I am trying to unit test my iPhone application. I have created a new target and called it "LogicTests". But now I need to use a class called "Spaceship" inside the test. How can I do that?

UPDATE 1:

I made the Spaceship.m available to the unit testing target and that particular error was gone. Now I have different problem. The Spaceship.m file reference to the Cocos2d library. How can I add a reference to the Cocos2d library in the unit testing target. I tried right clicking the Link binary with libraries option and then adding the cocos2d framework but it gave me 153 errors or something.

To include it in that target, click on Spaceship.m , get the file's Info (Command-I), and make sure "LogicTests" is checked under the Target tab.

Beyond that, make sure you add

#import "Spaceship.h"

To the top of the particular test class. Good luck!

在Xcode 4中,按:Alt-Command-1,然后检查Target Membership选项卡下是否选中了“LogicTests”。

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