views:

523

answers:

1

Is it possible to have an Xcode project file which contains both the Cocoa (MacOSX) and CocoaTouch (iPhone) versions of a component?

I thought I was getting close until I realized that you need to set "Base SDK for All Configurations" in the Project Settings in order for the cross-compiler to be called (and for any CocoaTouch frameworks to be found and properly handled by Xcode).

Since that is a project-wide setting, I don't know how I can have both MacOSX and iPhoneOS targets in the same project file.

Specifying:

SDKROOT = iphoneos3.0

in an xcconfig file (used by iPhone-only targets) did not seem to work.

+1  A: 

Yes, you can, but there are some glitches.

Okay first off, you can override any Base SDK in several ways. One is that you can on the gear at the bottom of the inspector and "Add Build Setting Condition" which lets you conditionalize any build settings based on things like the target architecture, etc.

Second, even if you have a project wide setting, it can been overriden per target. So if you have seperate targets you can just add an SDKROOT to the to the various targets with their SDKROOT.

Third, the SDK selected in the popup in your Xcode window overrides evertyhing else. So if you have something besides "Base SDK" in that popup it will get used. Also, if you do switch that (lets say from "Base SDK" to "iPhone Simulator") and then you switch targets to a target that does not support the currently selected SDK it will appear to deselect, but it doesn't actually correctly autorevert the Base SDK, you need to reselect it in the pop up.

I still can't consistently get multiple archs building together properly as part of an aggregate (for instance, having an OS X target that preprocesses some resource built so that it can be used as a build phase in a later target building an iPhone app).

Louis Gerbarg
Got it to work. I had a stray SDKROOT in a dependent target.Also, concerning your "reselect" trick, I've noticed that changing SDKROOT is a bit brittle in Xcode, and I usually close+reopen my project file whenever I change that.Thanks for the help! If I ever use (and solve) the multiple archs situation you describe, I'll add a comment here.
jhoule