加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xcode – OSX 10.x向后兼容性的最佳实践

发布时间:2020-12-14 17:41:08 所属栏目:百科 来源:网络整理
导读:我对OS X开发相对较新(使用XCode) 我最近测试了一个我一直在朋友MacBook上工作的应用程序,并遇到了一个问题. 我在运行Snow Leopard 10.6.5的MacBook上构建了应用程序,而我朋友的Mac运行的是早期版本(我认为Leopard 10.5.x).该应用程序没有启动,只是显示一条
我对OS X开发相对较新(使用XCode)

我最近测试了一个我一直在朋友MacBook上工作的应用程序,并遇到了一个问题.

我在运行Snow Leopard 10.6.5的MacBook上构建了应用程序,而我朋友的Mac运行的是早期版本(我认为Leopard 10.5.x).该应用程序没有启动,只是显示一条消息,说操作系统对于应用程序而言太旧了.

应用程序本身非常基础,不需要任何第三方库或API.

确保可以使用相同安装程序的最佳方法是什么?我不需要能够处理比10.4更早的任何东西.

解决方法

您需要将项目或应用程序的Mac OS X部署目标设置(密钥名称:MACOSX_DEPLOYMENT_TARGET)更改为您要支持的最旧的操作系统.

以下是有关如何更改目标的基本构建设置的文档:http://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Building/Building.html#//apple_ref/doc/uid/TP40010215-CH9-SW2

这里有一个指向文档的链接,其中包含更多信息,可以为多个版本的操作系统构建.
我找不到在线链接,因此这是您本地安装的文档的链接.
file:///Library/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone4_0.iPhoneLibrary.docset/Contents/Resources/Documents/documentation/DeveloperTools/Conceptual/XcodeProjectManagement/210-Building_Products/building.html#//apple_ref/doc/uid/TP40002693-SW38

这是一个摘录:

You can develop software that can be deployed on,and take advantage of features from,different versions of iPhone OS or Mac OS X,including versions different from the one you are developing for. This capability is known as cross-development.

In order to take advantage of cross-development,you must install the Mac OS X SDKs for the OS versions you plan on targeting. Then,in your projects,specify which SDK to use when building your products. You can also specify the earliest Mac OS X release on which the software must run.

In some cases,Apple distributes an SDK for an upcoming version of the operating system as a seed,allowing you to prepare your application to work with future versions of the Mac OS X before they have been released to the general public.

Important: Cross-development in Xcode requires native targets.

To set up your Xcode project to target multiple Mac OS X releases,take the following steps:

?Choose an SDK. Select your project in the Groups & Files list and choose File > Get Info. In the General pane of the Project Info window,choose the SDK from the Base SDK for All Configurations pop-up menu. When you choose an SDK,Xcode builds targets in your project against the set of headers corresponding to the specified version of the OS,and links against the stub libraries in that SDK. This allows you to build products on your development computer that can be run on the OS release targeted by the SDK. Your software can use features available in system versions up to and including the one you select.

You can also specify the Base SDK through the Base SDK (SDKROOT) build setting.

?Choose a deployment version Mac OS X. If your software must run on a range of operating system versions,choose a Mac OS X deployment operating system for each individual target that requires one. The deployment operating system identifies the earliest system version on which the software can run. By default,this is set to the version of the OS corresponding to the SDK version.
To set the deployment version for a target:

? a. Select the target in the Groups & Files list and open an Info window. Click Build to open the Build pane.

b. Find the Deployment Target (MACOSX_DEPLOYMENT_TARGET) or iPhone OS Deployment Target (IPHONEOS_DEPLOYMENT_TARGET) build setting (depending on which platform you’re developing for) and choose a deployment operating system from the pop-up menu in the Value column.

For each target,supply a prefix file that takes into account the selected SDK. To use an umbrella framework header from an SDK as your prefix file,add the appropriate #include directive to your target’s prefix file instead of setting a Prefix Header path to the umbrella framework header directly. There is a lot more to successfully developing software for multiple versions of the Mac OS. For more information see SDK Compatibility Guide.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读