Reputation: 16339
I added class files from another project to my new iPhone Window for the first time. The class is a simple class that defines a polygon, and subclasses NSObject. As part of the standard template for an Objective C class, this class definition imports Cocoa.h
#import <Cocoa/Cocoa.h>
However, just by adding this class, I'm getting an error that
Cocoa/Cocoa.h:No such file or directory.
I don't understand this because the exact same line occurs in another class definition (the controller) within the same project.
Upvotes: 8
Views: 16372
Reputation: 6093
I had this problem occur when I accidentally overwrote the testApp-Prefix.pch code.
This then deleted the code adding #import (as mentioned above)
Once I noticed and undid the error disappeared
Upvotes: 0
Reputation: 1539
Project Target->"Build Settings"->"Base SDK", then select "Latest OS X(OS X 10.x)"
Upvotes: 0
Reputation: 753
This can happen when you generate a NSManagedObject subclass out of your datamodel (in an iPhone project), I assume in later versions of XCode this will be fixed.
Upvotes: 1
Reputation: 6023
On the iPhone you generally use UIKit instead of Cocoa, which is for Mac OS X.
#import <UIKit/UIKit.h>
You might import just the Foundation framework in a model class that doesn't reference any user interface stuff.
#import <Foundation/Foundation.h>
Upvotes: 7
Reputation: 32104
Subclasses of NSObject (at least on the iPhone) do not import the Cocoa.h header. Instead, they import Foundation.h:
#import <Foundation/Foundation.h>
Upvotes: 22