开发者

Best practice for OSX 10.x backwards compatability

I am relative开发者_如何学Goly new to OS X development (using XCode)

I recently tested an app I've been working on a friends MacBook, and ran into a problem.

I built the app on my MacBook that is running Snow Leopard 10.6.5, whereas my friend's Mac was running an earlier version (I think Leopard 10.5.x). The app didn't start and just showed a message saying the operating system was too old for the app.

The app itself is very basic, and does not require any third party libraries or APIs.

What's the best way to ensure that the same installer can be used? I don't need to be able handle anything older than say 10.4.


You need to change the Mac OS X deployment target settings (key name: MACOSX_DEPLOYMENT_TARGET) of your project or application to the oldest OS you want to support.

Here is the documentation on how to change basic build settings for a target: http://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Building/Building.html#//apple_ref/doc/uid/TP40010215-CH9-SW2

And here is a link to the documentation with more info to build for multiple releases of an OS. I couldn't find the online link, so this is a link to your locally installed documentation. 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

Here is an extract:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜