Conditional Linking to System Frameworks

本文介绍如何在Xcode中为不同运行环境(iPhone模拟器与实际设备)配置应用程序目标,使其分别链接到不同的系统框架。例如,CFNetwork API在iPhone SDK中针对实际设备时作为一个独立框架存在,而在iPhone模拟器上则作为CoreServices框架的一部分。文章详细说明了设置过程。

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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值