Conditional Linking to System Frameworks – CoreServices – iPhone Dev SDK Forum

Conditional Linking to System Frameworks – CoreServices – iPhone Dev SDK Forum

For 2.2.x…

There may be occasions when you need to configure your application target so that it links against one framework to run on the iPhone Simulator and another framework to run on a device. For example, the CFNetwork API is a stand-alone framework (CFNetwork.framework) in the iPhone SDK for a device but a subframework of the Core Services framework (CoreServices.framework) on the iPhone SDK for the iPhone Simulator.

In this case, you need to specify the framework linking details for the CFNetwork API separately for the simulator and for a device. Follow these steps:

In Xcode, choose Project > Edit Active Target “<application_target>” to open the target editor.
Click the Build tab to display the build settings editor.
From the Show pop-up menu, choose All Settings.
Select Linking > Other Linker Flags.
Add the device linking details:
Select the Linking > Other Linker Flags build setting.
Choose Add Build Setting Condition from the Action (gear) pop-up menu.
In the Value column, enter -framework CFNetwork.
From the Any SDK pop-up menu in the Title column, choose Device – iPhone.
Add the simulator linking details:
Select the Linking > Other Linker Flags build setting.
Choose Add Build Setting Condition from the Action (gear) pop-up menu.
In the Value column, enter -framework CoreServices.
From the Any SDK pop-up menu in the Title column, choose Simulator – iPhone.

And add this to the applicable files…

[sourcecode lang=”cpp”]
#if TARGET_IPHONE_SIMULATOR
#import
#else
#import
#endif
[/sourcecode]

For 3.0, I had to just use the CFNetwork import above and in both of the “Other Linker Flags” use CFNetwork.