Reputation: 31362
I'm working on a Core Data application. I'd like to create interfaces on both the Mac and on iPhone, with both sharing the same model code.
Is it possible to set up an Xcode project to have both OS X (x86_64 10.6) and iPhone targets? Or is there a better way to do this?
Upvotes: 2
Views: 1047
Reputation: 2593
Lets assume your application is called Foo.
Add a new Target, make this a Cocoa Touch static library.
Add the frameworks you need to both
targets. CoreData.framework
Foundation.framework
Now you can build your project for inclusion with a Cocoa or Cocoa Touch project.
Upvotes: 2
Reputation: 43462
You can setup a single project with both iPhone and Mac targets, but there are a lot of gotchas and somethings don't work quite right. It is sort of lame that it works so poorly.
The best way to share model code is to separate it into its own project and build it as a static library, then include that in your mac and iPhone projects as a cross project link. It is. Here is a blog post explaining how to setup code sharing between multiple iPhone projects in detail. The same technique also works for sharing the static library in a mac app.
Upvotes: 8