I'm working on a project which shall contain two targets. One for building a Framework to use in Mac development and another to create a static library to use in iPhone development.
In the common code it's no problem to #ifdef between the platforms, but I just can't get the targets and dependencies right.
The first question is, which base SDK to use? For example if I use Mac 10.5 i can't include the UIKit framework (it is marked red and doesn't show the header files if i expand it). Even if the target that actually links against it builds for iPhone OS..
The other question is, how about the Foundation.framework, or stuff like Security.framework? How to deal with them, as I can only include one of the versions (Mac or iPhone SDK)...
Anyone has an advice for me? I'd like to have a clean project structure and definitely the same codebase for both targets... Are configurations the way to go?
Thanks!
Just to let you know:
I ended up having one project with different targets for the different platforms. But I didn't include the framework I depend on in the targets itself, but rather added them to the Other Linker Flags build settings:
-framework Foundation -framework Security
You can check it out in the project I did on github.
Probably the easiest (in terms of what you have to do) way of doing it is two projects (which you can wrap up as sub-projects of a dummy umbrella project if you like) which use the same sets of sources—one targeting Mac OS X, the other iPhone OS.
Alternatively, can you not create two separate targets within the same project, and alter the “Base SDK” from the “Build” tab of the “Get Info” window for each? I don't have Xcode in front of me to check, but I think it'll let you do this.
(Of course, with either approach, you can add a third target: a static library for the simulator, which will be useful when testing!)
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