Posted by: bearc0025 | May 6, 2009

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…

#if TARGET_IPHONE_SIMULATOR
#import <CoreServices/CoreServices.h>
#else
#import <CFNetwork/CFNetwork.h>
#endif

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

Advertisements

Responses

  1. Man .. Excellent .. Amazing .. I’ll bookmark your web site and take the feeds alsoI’m happy to search out a lot of helpful info here within the publish, we’d like develop more techniques in this regard, thank you for sharing. . . . . .


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: