简体   繁体   中英

How do I create in Xcode an iPhone project specifying at project creation time the SDK version I want to use?

With the latest Xcode and SDK 3.0 beta when you create a new iPhone project, Xcode creates an SDK 3.0 project. If I want to revert to SDK 2.2.1 after the project has been created, I need to change something in the generated source code files since some of the APIs have changed. Is there a simple way to specify at project creation time the SDK I want to use explicitly?

Thank you in advance

I can't comment specifically on iPhone SDK 3.0 as it's covered under NDA; there's a forum for disclosed developers at devforums.apple.com. But Roger Nolan is half right and half wrong. He's half right in that when any SDK is updated, the examples and templates in that SDK are updated to exploit it. That is, the templates may specifically use the new APIs in that SDK, and the code might plain just not work with earlier SDKs.

That said, you can save project templates from earlier SDKs and install them in a local directory (like ~/Library/Application Support/Developer/Shared/Xcode/Project Templates) for use with later versions of Xcode. The project template format itself hasn't changed; templates should be forwards and backwards compatible, but the content of the templates is usually locked to the SDK version it ships with and later.

Mr. Nolan is half wrong about building against earlier OS versions with later SDKs. That's why the earlier SDK packages are provided with the later distributions (they're not there just to make the downloads take longer). You can deploy against older OS versions with a newer SDK by setting the Deployment Target build setting.

There is the minor detail in that you probably shouldn't deploy production applications produced by a pre-production toolchain. But once version N is officially released, you should be able to use its toolchain to build for N-1, N-2, etc.

Provided that you're not using any new features in the 3.0 API, you should be able to select the Active SDK from the dropdown menu on the upper left corner of your Xcode project window. Simply select "Device - 2.2.1" or "Simulator - 2.2.1"

Xcode defaults to the newest SDK installed, and I'm not aware of any method to change that behavior.

I made it a habit to set the base SDK to 2.0 in the project properties right after I create the project.

When using a Beta toolchain, you should install it alongside the latest released toolchain, not in place of it. Create your projects in the production toolchain, then open them with the beta toolchain to to do compatibility testing.

You will need the released toolchain anyway in order to do distribution builds. You should not build for distribution with a beta toolchain.

There is not according to Apple. Comments to my posting from Can Berk Güder say otherwise. I would not suggest following his example - it's a lottery hoping Apple can't see what you are doing or that you do not fall foul of a 3.0 defect.

You can use Xcode to build for earlier versions of the OS but if you need to build with multiple SDKs you should install them. Xcode supports multiple installations on a single machine and the install instructions document how to do it.

If you want to use the 3.0 SDK you can't built for OS 2.2.1 and submit that application to the app store - according to Apple's guidelines. They say that you must also install the 2.2.1 SDK and build with that. You can build 2.2 compatible apps but you are using beta tools which might introduce bugs.

It's one of those things that you can do as an intellectual exerxcise but, it's just not worth the risk for a real app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM