views:

1555

answers:

6

I am trying to perform some unit testing on the iphone but for some reason I cannot get it to build the executable

I have downloaded TestMyApp from the Standford lecture slides and that compiles and runs perfectly. I have created a test project and even gone as far as to use the test code from the Stanford sample but for some reason depsite every setting looking identical I get the following precompiler errors:

/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:13:26: error: AppKit/AppKit.h: No such file or directory /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:14:30: error: CoreData/CoreData.h: No such file or directory

N.B> Only other point to note is that Im running it on a "tweaked" xcode install on a PPC not an Intel mac

+1  A: 

AppKit is not available for iPhone development. Looks like you downloaded a desktop mac app project. iPhone dev uses UIKit in place of AppKit. CoreData is not available for iPhone dev as well.

Try setting up a Desktop cocoa application, and these frameworks and objects should be available.

For unit testing an iPhone app, the Google Toolbox for mac is useful.

GTM iPhone docs

Ryan Townshend
I am building it as a Cocoa Touch application, but even trying to use the Google testing framework I get the exact same errors
tigermain
-1: Core Data is available in the iPhone 3.0 SDK
Alex Reynolds
A: 

Do you have the iPhone SDK 2.2 installed? Without using the GTM for iPhone, OCunit doesn't work with iPhone SDK < 2.2.

I have been working with the Stanford example code as well. When I try to set up my own project, I wasn't able to get my tests to run. So, I took the Stanford example projects and renamed everything. Now the OCunit testing is working fine.

hanleyp
Yes I have the 2.2 SDK installed, but the Stanford example runs fine even when output is set to iPhone
tigermain
+2  A: 

If you right click on your unit test target and select the "get info" menu you will see your target options. At the bottom of the pane, you'll see a section called "User Defined": remove the entry containing the path to cocoa.h. I don't remember the name of this entry as I removed it, but this fixes the same problem I had before.

I also changed Base SDK to be Device - iPhone OS 2.2 and other linker flags to -framework Foundation -framework SentestingKit

Pierre C.
It works! How to make it changed in every target I create?
Mykola Golubyev
+1  A: 

You can find instructions and a sample project on Sen:te web site: http://www.sente.ch/s/?p=535&amp;lang=en

nst
A: 

Do not use the Sen:te thing for testing any classes that make use of the UIKit framework. It will fail with code 139. Use Google's GTM.

tmadsen
A: 

I had to remove the value for GCC_PREFIX_HEADER in the "User Defined Section". It was using $(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h

Once I removed that, I got past this problem.