I am trying to build a couple of apps within an XCode workspace: One app will be an iOS app and another will be a Mac OS X app. I'd like to have a certain set of classes that get included in both versions of the app. I'm struggling to figure out what kind of project structure would best support some code that is shared, some that is specific to the iOS app, and some that is specific to the Mac app. Is there a best practice for doing this kind of thing in XCode in general or XCode 4 specifically?
Should I be creating a library project for the shared code and creating 2 different targets for the iOS and Mac OS X builds of the library? The build-in project templates seem to want me to pick either a Mac OS X library or an iOS library, and I'm not sure if it's easy to make a project based on one of those templates work for both targets.
Should I instead be creating different projects for the iOS library, the Mac OS X library, the iOS app, and the Max OS X app? In this case, how can I easily have the library code shared between the iOS library and Mac OS X library projects?
A workspace is an Xcode document that groups projects and other documents so you can work on them together. A workspace can contain any number of Xcode projects, plus any other files you want to include.
To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.
You won't be able to make a library in the sense of a shared library file that you can link against, because code for iOS is compiled for ARM processors whereas code for OS X is compiled for Intel processors (different machine code instruction sets).
You should probably just make the code that will be shared in to a separate project and then add the project itself as a dependency.
And here's another SO question that's similar to yours about porting from one platform to the other
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With