简体   繁体   English

如何在Xcode中创建一个iPhone项目,在项目创建时指定我想要使用的SDK版本?

[英]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. 在创建新的iPhone项目时,使用最新的Xcode和SDK 3.0测试版,Xcode创建了一个SDK 3.0项目。 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. 如果我想在项目创建后恢复到SDK 2.2.1,我需要更改生成的源代码文件中的某些内容,因为某些API已经更改。 Is there a simple way to specify at project creation time the SDK I want to use explicitly? 是否有一种简单的方法可以在项目创建时指定我想明确使用的SDK?

Thank you in advance 先感谢您

I can't comment specifically on iPhone SDK 3.0 as it's covered under NDA; 我不能专门评论iPhone SDK 3.0,因为它涵盖在NDA之下; there's a forum for disclosed developers at devforums.apple.com. 在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. 当更新任何SDK时,他的一半是正确的,该SDK中的示例和模板会更新以利用它。 That is, the templates may specifically use the new APIs in that SDK, and the code might plain just not work with earlier SDKs. 也就是说,模板可以专门使用该SDK中的新API,并且代码可能只是不适用于早期的SDK。

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. 也就是说,您可以保存早期SDK中的项目模板,并将它们安装在本地目录(如〜/ Library / Application Support / Developer / Shared / Xcode / Project Templates)中,以便与更高版本的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. 模板应该向前和向后兼容,但模板的内容通常会锁定到它随附的SDK版本以及之后。

Mr. Nolan is half wrong about building against earlier OS versions with later SDKs. Nolan先生与使用更新的SDK构建早期操作系统版本是错误的。 That's why the earlier SDK packages are provided with the later distributions (they're not there just to make the downloads take longer). 这就是为什么早期的SDK软件包与后来的发行版一起提供的原因(它们并不只是为了让下载时间更长)。 You can deploy against older OS versions with a newer SDK by setting the Deployment Target build setting. 通过设置“部署目标”构建设置,您可以使用较新的SDK针对较旧的OS版本进行部署。

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. 但是一旦版本N正式发布,你应该可以使用它的工具链来构建N-1,N-2等。

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. 如果您没有使用3.0 API中的任何新功能,您应该可以从Xcode项目窗口左上角的下拉菜单中选择Active SDK。 Simply select "Device - 2.2.1" or "Simulator - 2.2.1" 只需选择“设备 - 2.2.1”或“模拟器 - 2.2.1”

Xcode defaults to the newest SDK installed, and I'm not aware of any method to change that behavior. Xcode默认安装了最新的SDK,我不知道有任何方法可以改变这种行为。

I made it a habit to set the base SDK to 2.0 in the project properties right after I create the project. 我养成了在创建项目后立即在项目属性中将基础SDK设置为2.0的习惯。

When using a Beta toolchain, you should install it alongside the latest released toolchain, not in place of it. 使用Beta工具链时,应将其最新发布的工具链一起安装,而不是代替它。 Create your projects in the production toolchain, then open them with the beta toolchain to to do compatibility testing. 在生产工具链中创建项目,然后使用beta工具链打开它们以进行兼容性测试。

You will need the released toolchain anyway in order to do distribution builds. 无论如何,您将需要已发布的工具链才能进行分发构建。 You should not build for distribution with a beta toolchain. 您不应该使用beta工具链进行分发。

There is not according to Apple. 根据Apple没有。 Comments to my posting from Can Berk Güder say otherwise. 我对CanBerkGüder发布的评论说不然。 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. 我不建议跟随他的例子 - 这是一个抽奖,希望苹果公司看不到你在做什么,或者你不会违反3.0缺陷。

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为早期版本的操作系统构建,但如果您需要使用多个SDK进行构建,则应安装它们。 Xcode supports multiple installations on a single machine and the install instructions document how to do it. Xcode支持在一台机器上进行多次安装,安装说明记录了如何执行此操作。

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. 如果您想使用3.0 SDK,则无法为OS 2.2.1构建并将该应用程序提交到应用商店 - 根据Apple的指南。 They say that you must also install the 2.2.1 SDK and build with that. 他们说你还必须安装2.2.1 SDK并使用它进行构建。 You can build 2.2 compatible apps but you are using beta tools which might introduce bugs. 您可以构建2.2兼容的应用程序,但您使用的是可能会引入错误的beta工具。

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. 这是你作为一个知识分子运动可以做的事情之一,但是,它不值得冒真正的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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