Conditional Linking to System Frameworks

来源:互联网 发布:canvasjs.min.js 编辑:程序博客网 时间:2024/04/28 21:53

Conditional Linking to System Frameworks

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:

  1. In Xcode, choose Project > Edit Active Target “<application_target>” to open the target editor.

  2. Click the Build tab to display the build settings editor.

  3. From the Show pop-up menu, choose All Settings.

  4. Select Linking > Other Linker Flags.

  5. Add the device linking details:

    1. Select the Linking > Other Linker Flags build setting.

    2. Choose Add Build Setting Condition from the Action (gear) pop-up menu.

    3. In the Value column, enter -framework CFNetwork.

    4. From the Any SDK pop-up menu in the Title column, choose Device - iPhone.

  6. Add the simulator linking details:

    1. Select the Linking > Other Linker Flags build setting.

    2. Choose Add Build Setting Condition from the Action (gear) pop-up menu.

    3. In the Value column, enter -framework CoreServices.

    4. From the Any SDK pop-up menu in the Title column, choose Simulator - iPhone.



    https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/DevelopmentEnvironmentOverview/chapter_4_section_7.html