Set up your Xcode 4 workspace to create a library for both Mac and iOS

I am trying to create a couple of applications in the Xcode workspace: one application will be an iOS application and the other a Mac OS X. I would like to have a specific set of classes that are included in both versions of the application. I'm struggling to figure out which project structure best supports some common code, some of which relate to the iOS application, and some relate to the Mac application. Is there any best practice for this kind of thing in Xcode in general or Xcode 4?

Should I create a library project for common code and create 2 different objects to build the iOS and Mac OS X libraries? Embedded project templates seem to want me to choose the Mac OS X library or the iOS library, and I'm not sure if it is easy to make a project based on one of these templates for both purposes.

Should I instead create different projects for the iOS library, Mac OS X library, iOS application and Max OS X application? In this case, how can I easily get the library code shared between the iOS library and Mac OS X library projects?

+7
source share
1 answer

You cannot create a library in the sense of a shared library file with which you can establish a connection, since the code for iOS is compiled for ARM processors, while the code for OS X is compiled for Intel processors (different machine code instruction sets).

You should probably just make the code that will be used for a separate project, and then add the project itself as a dependency .

And here is another question, similar to your question about porting from one platform to another

+4
source

All Articles