简体   繁体   English

是否可以在Xcode 5上安装iOS 6 SDK?

[英]Is it possible to install iOS 6 SDK on Xcode 5?

Xcode 5 has a preferences pane that allow one to download iPhone 6.1 simulator, however I can't find a place where it allows downloading of iOS 6 SDK, thus it is not possible to set the active SDK to iOS 6 when developing with Xcode 5. Is there a workaround that would allow Xcode 5 to install iOS 6 SDK? Xcode 5有一个首选项窗格,允许用户下载iPhone 6.1模拟器,但我找不到允许下载iOS 6 SDK的地方,因此在使用Xcode 5进行开发时无法将活动SDK设置为iOS 6 。是否有允许Xcode 5安装iOS 6 SDK的解决方法?

EDIT: 编辑:

Workarounds should no longer be necessary now that Xcode 5 is generally available and allows you to download previous versions of the SDK. 现在,Xcode 5通常可用,并且允许您下载SDK的先前版本,因此不再需要解决方法。

在此输入图像描述

EDIT: Starting Feb 1, 2014, Apple will no longer accept pre-iOS7 apps for submission to App Store. 编辑:从2014年2月1日开始,Apple将不再接受iOS7之前的应用程序提交到App Store。 So while this technique still works, it will not be useful for most readers. 因此,尽管这种技术仍然有效,但它对大多数读者来说并没有用。


Yes, this is fine. 是的,这很好。 I still build with iOS 4.3 for one project (it's been awhile since we updated; but they still accepted it after iOS 6 came out), and I currently build 10.5 apps with Xcode 5. 我仍然使用iOS 4.3为一个项目构建(自我们更新以来已经有一段时间了;但他们仍然在iOS 6发布后接受它),而且我目前使用Xcode 5构建了10.5个应用程序。

See How to point Xcode to an old SDK so it can be used as a "Base SDK"? 请参阅如何将Xcode指向旧的SDK,以便它可以用作“基础SDK”? for details on how to set it up. 有关如何设置的详细信息。 You can use my fix-xcode script to link everything for you every time you upgrade. 每次升级时,您都可以使用我的fix-xcode脚本为您链接所有内容。

The only trick is getting the old SDKs. 唯一的技巧是获取旧的SDK。 If you don't have them, you generally need to download old versions of Xcode (still available on developer.apple.com ), open the installer package, and hunt around to find the SDK you need. 如果你没有它们,你通常需要下载旧版本的Xcode(仍然可以在developer.apple.com上找到 ),打开安装程序包,然后寻找你需要的SDK。

SDKs can be found within the installer package at: SDK可以在安装程序包中找到:

Xcode.app/Contents/Developer/Platforms/ Xcode.app/Contents/Developer/Platforms/

I was also running the same problem when I updated to xcode 5 it removed older sdk. 当我更新到xcode 5时它也运行了同样的问题它删除了旧的sdk。 But I taken the copy of older SDK from another computer and the same you can download from following link. 但我从另一台计算机上获取了旧版SDK的副本,您可以从以下链接下载。

http://www.4shared.com/zip/NlPgsxz6/iPhoneOS61sdk.html http://www.4shared.com/zip/NlPgsxz6/iPhoneOS61sdk.html
(www.4shared.com test account test@yopmail.com/test) (www.4shared.com测试帐号test@yopmail.com/test)

There are 2 ways to work with. 有两种方法可以使用。

1) Unzip and paste this folder to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs & restart the xcode. 1)将此文件夹解压缩并粘贴到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs并重新启动xcode。

But this might again removed by Xcode if you update xcode. 但是如果你更新xcode,这可能会被Xcode删除。

2) Another way is Unzip and paste where you want and go to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs and create a symbolic link here, so that the SDK will remain same even if you update the Xcode. 2)另一种方法是解压缩并粘贴到你想要的位置,然后转到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs并在此处创建一个符号链接,这样即使SDK仍然保持相同你更新Xcode。

Another change I made, Build Setting > Architectures > standard (not 64) so list all the versions of Deployment Target 我做了另一项更改,Build Setting> Architectures> standard(而不是64),因此列出了Deployment Target的所有版本

No need to download the zip if you only wanted to change the deployment target. 如果您只想更改部署目标,则无需下载zip。

Here are some screenshots. 这是一些截图。 在此输入图像描述在此输入图像描述

Yes, I just solved the problem today. 是的,我今天刚解决了这个问题。

  1. Find the SDK file, like iPhoneOS6.1.sdk, in your or your friend's older Xcode directory. 在您或您朋友的旧Xcode目录中找到SDK文件,如iPhoneOS6.1.sdk。
  2. Copy & put it into the Xcode 5 directory : /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs. 复制并将其放入Xcode 5目录:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs。

在此输入图像描述

Then you can choose the SDK like below : 然后你可以选择如下的SDK:

在此输入图像描述

Hope this helps you. 希望这对你有所帮助。

Find and download old SDK. 查找并下载旧SDK。 Older SDKs are found here . 较旧的SDK可在此处​​找到

I have copied the xcode.app directory as Xcode_4.6.3.app. 我已将xcode.app目录复制为Xcode_4.6.3.app。

Now you can test and debug in both xcode versions. 现在,您可以在两个xcode版本中进行测试和调试。 You have to run them from the corresponding folders or create shortcuts in your desktop. 您必须从相应的文件夹运行它们或在桌面上创建快捷方式。 When building from command line give the parameter as iPhoneOS6.1 instead of iPhoneOS7.0 从命令行构建时,将参数设置为iPhoneOS6.1而不是iPhoneOS7.0

This worked great for me in Xcode5 and iOS. 这在Xcode5和iOS中对我很有用。

Go to into Xcode5's SDK dir. 转到Xcode5的SDK目录。 Its usually located at: 它通常位于:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs

Add a symbolic link to the old SDK like this: 像这样添加旧SDK的符号链接:

sudo ln -s /Applications/Xcode_4.6.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk iPhoneOS6.1.sdk

Or more accurately from anywhere in the command line, 或者更准确地从命令行中的任何位置,

sudo ln -s /Applications/Xcode_4.6.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk

You can download the older SDK and install it in 您可以下载旧版SDK并将其安装在其中

Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

folder. 夹。 Logout + Login just to make sure the changes take effect and you should see the older SDK in your new XCode 注销+登录只是为了确保更改生效,您应该在新的XCode中看到旧的SDK

Just to add, you can actually download old versions of the simulator with Xcode 5 itself - just go to preferences and you'll find them under Downloads: 只需添加,您实际上可以使用Xcode 5本身下载旧版本的模拟器 - 只需转到首选项,您就可以在下载中找到它们:

在此输入图像描述

  • Download Xcode 4.6.x from the Apple Dev Center: https://developer.apple.com/downloads/index.action 从Apple开发中心下载Xcode 4.6.x: https//developer.apple.com/downloads/index.action
  • Create a folder called Xcode4 within the Applications folder and drag-n-drop the downloaded dmg there. 在Applications文件夹中创建一个名为Xcode4的文件夹,然后将下载的dmg拖放到那里。
  • Open a terminal window 打开终端窗口

     $sudo cp -R /Applications/Xcode4/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ 
  • You will be prompt to enter a password since you're inside a system folder 由于您在系统文件夹中,因此系统会提示您输入密码

  • Open Xcode 5 and you should now see both SDKs 打开Xcode 5,您现在应该看到两个SDK

Just for me the easiest solution: 对我来说最简单的解决方案:

  1. Locate an older SDK like for example "iPhoneOS6.1 sdk" in an older version of xcode for example. 例如,在较旧版本的xcode中找到较旧的SDK,例如“iPhoneOS6.1 sdk”。 If you haven't, you can downlad it from Apple Developer server at this address: https://developer.apple.com/downloads/index.action?name=Xcode When you open the xcode.dmg you can find it by opening the Xcode.app (right click and "show contents") and go to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1 sdk 如果还没有,可以从Apple Developer服务器上获取此地址: https//developer.apple.com/downloads/index.action? name = Xcode当你打开xcode.dmg时,你可以通过打开它来找到它Xcode.app(右击和“显示内容”)并转到目录/开发人员/平台/ iPhoneOS.platform / Developer / SDKs / iPhoneOS6.1 sdk 在此输入图像描述
  2. Simple Copy the folder iPhoneOS6.X sdk and paste it in your xcode.app 简单复制文件夹iPhoneOS6.X sdk并将其粘贴到xcode.app中
    • right click on your xcode.app in Applications folder. 右键单击Applications文件夹中的xcode.app。
    • Go to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ 转到目录/开发人员/平台/ iPhoneOS.platform / Developer / SDKs /
    • Just paste here. 只需粘贴在这里

在此输入图像描述

  1. Close your xcode app and re-open it again. 关闭您的xcode应用程序,然后重新打开它。

To test an app in iOS 6 on your simulator: - Just choose iOS 6.0 in your active sheme. 要在模拟器上测试iOS 6中的应用程序: - 只需在活动的sheme中选择iOS 6.0即可。 在此输入图像描述

To build your app in iOS 6, so the design of your app will be the older design on an iPhone with iOS 7 also: - Choose iOS6.1 in Targets - Base SDK 要在iOS 6中构建您的应用程序,因此您的应用程序的设计将是iOS 7上的旧设计: - 在目标中选择iOS6.1 - 基本SDK

在此输入图像描述

Just note : When you change the base SDK in your Targets, iOS 7.0 won't be available anymore for building on the simulator ! 请注意:当您更改目标中的基础SDK时,iOS 7.0将不再可用于在模拟器上构建!

Can do this , But not really necessary 可以做到这一点 ,但不是真的有必要

How to do this 这该怎么做

Jason Lee got the answer. 杰森李得到了答案。 When installing xCode I preferred keeping previous installations rather than replacing them. 安装xCode时,我更喜欢保留以前的安装而不是替换它们。 So I have these in my installation Folder 所以我在我的安装文件夹中有这些

在此输入图像描述

So /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs Contain different sdks. 所以/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs包含不同的sdks。 (Replace Xcode.app with correct number) copy previous sdks to (将Xcode.app替换为正确的数字)将以前的sdks复制到

/Applications/Xcode 3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs

Here is my folder after I copied one. 复制之后,这是我的文件夹。

在此输入图像描述

Now restart xCode and you can set previous versions of sdks as base sdk. 现在重新启动xCode,您可以将以前版本的sdks设置为基本sdk。

Why it is not necessary 为什么没有必要

Refering Apple Documentaion 参考Apple Documentaion

To use a particular SDK for an Xcode project, make two selections in your project's build settings. 要将特定SDK用于Xcode项目,请在项目的构建设置中进行两项选择。

  1. Choose a deployment target . 选择部署目标

    This identifies the earliest OS version on which your software can run. 这标识了您的软件可以运行的最早的操作系统版本。

  2. Choose a base SDK 选择基本SDK

    Your software can use features available in OS versions up to and including the one corresponding to the base SDK. 您的软件可以使用操作系统版本中可用的功能,包括与基本SDK相对应的功能。 By default , Xcode sets this to the newest OS supported by Xcode. 默认情况下,Xcode将此设置为Xcode支持的最新操作系统。

Rule is Use latest as base SDK and set deployment target to the minimum version app supposed to run 规则是使用latest作为基本SDK并将部署目标设置为应运行的最小版本应用程序

For example you can use iOS 7 as base sdk and set iOS 6 as deployment target. 例如,您可以将iOS 7用作基本sdk,并将iOS 6设置为部署目标。 Run on iOS 6 simulator to test how it works on iOS 6. Install simulator if not available with list of simulators. 在iOS 6模拟器上运行以测试它在iOS 6上的工作方式。如果模拟器列表不可用,请安装模拟器。

在此输入图像描述

Additionaly You can unconditionally use features upto iOS 6. And Conditionally you can support new features of iOS 7 for new updated devices while supporting previous versions. 另外,您可以无条件地使用iOS 6以上的功能。并且有条件地,您可以支持iOS 7的新功能,以支持新版本,同时支持以前的版本。

This can be done using Weakly Linked Classes , Weakly Linked Methods , Functions , and Symbols 这可以使用弱链接类弱链接方法函数符号来完成

https://developer.apple.com/library/ios/documentation/developertools/conceptual/cross_development/Using/using.html#//apple_ref/doc/uid/20002000-SW3 https://developer.apple.com/library/ios/documentation/developertools/conceptual/cross_development/Using/using.html#//apple_ref/doc/uid/20002000-SW3

Weak Linking 弱链接

Suppose in Xcode you set the deployment target (minimum required version) to iOS6 and the target SDK (maximum allowed version) to iOS7. 假设您在Xcode中将部署目标(最低要求版本)设置为iOS6,将目标SDK(最大允许版本)设置为iOS7。 During compilation, the compiler would weakly link any interfaces that were introduced in iOS7 while strongly linking earlier interfaces. 在编译期间,编译器会弱连接iOS7中引入的任何接口,同时强烈链接早期接口。 This would allow your application to continue running on iOS6 but still take advantage of newer features when they are available. 这将允许您的应用程序继续在iOS6上运行,但仍然可以利用更新的功能。

The other answers here are correct too, but I find the following steps to be the easiest: 这里的其他答案也是正确的,但我发现以下步骤是最简单的:

Just download Xcode 4.6.3 from the dev center link that says "Looking for an older version of Xcode?" 只需从开发中心链接下载Xcode 4.6.3,该链接显示“正在寻找旧版本的Xcode?” (currently points here ) and mount the dmg. (目前指向此处 )并安装dmg。

Then in terminal, copy the SDK files over: 然后在终端中,将SDK文件复制到:

cp -R /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/

Finally, relaunch Xcode and you're done. 最后,重新启动Xcode,你就完成了。

My app was transitioned to Xcode 5 seamlessly because it can still build with the original iOS Deployment Target that you set in the project (5.1 in my case). 我的应用程序无缝转换到Xcode 5,因为它仍然可以使用您在项目中设置的原始iOS部署目标(在我的情况下为5.1)进行构建。 If the new SDK doesn't cause some insurmountable problem, then why not build using it? 如果新的SDK不会导致一些难以解决的问题,那么为什么不使用它来构建呢? Surely there are many improvements under the hood. 当然,引擎盖下有很多改进。

For example, I will much prefer to use Xcode 5 instead of Xcode 4.6.3. 例如,我更喜欢使用Xcode 5而不是Xcode 4.6.3。 Why? 为什么? I'll get a lot more battery life because the UI scrolling of text/code areas in Xcode 5 no longer chews up an entire CPU thread. 我将获得更多的电池寿命,因为Xcode 5中的文本/代码区域的UI滚动不再咀嚼整个CPU线程。

Linking the 6.1 SDK into Xcode 5 as described in the other answers is one step. 如其他答案中所述,将6.1 SDK链接到X​​code 5是一步。 However this still doesn't solve the problem that running on iOS 7 new UI elements are taken, view controllers are made full-size etc. 但是,这仍然无法解决在iOS 7上运行新的UI元素,视图控制器是全尺寸等问题。

As described in this answer it is also required to switch the UI into legacy mode on iOS 7: 本回答所述,还需要在iOS 7上将UI切换为传统模式:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"UIUseLegacyUI"];
[[NSUserDefaults standardUserDefaults] synchronize];

Beware: This is an undocumented key and not recommended for App Store builds! 注意:这是一个未记录的密钥,不推荐用于App Store版本!

Also, in my experience while testing on the device I found that it only works the second time I launch the app even though I'm running the code fairly early in the app launch, in +[AppDelegate initialize] . 另外,根据我在设备上测试的经验,我发现它只在我第二次启动应用程序时工作,即使我在应用程序启动时很早就运行了代码,在+[AppDelegate initialize] Also there are subtle differences to a version built using Xcode 4.6. 使用Xcode 4.6构建的版本也存在细微差别。 For instance, transparent navigation bars behave differently (causing the view to be full-size). 例如,透明导航栏的行为不同(导致视图为全尺寸)。

However, since Xcode 4.6.3 crashes on Mavericks (at least for me, see rdar://15318883 ), this is at least a solution to continue using Xcode 5 for debugging. 但是,由于Xcode 4.6.3在Mavericks上崩溃(至少对我而言,请参阅rdar:// 15318883 ),这至少是继续使用Xcode 5进行调试的解决方案。

I downloaded XCode 4 and took iOS 6.1 SDK from it to the XCode 5 as described in other answers. 我按照其他答案的描述下载了XCode 4并将iOS 6.1 SDK从它带到了XCode 5。 Then I also installed iOS 6.1 Simulator (it was available in preferences). 然后我还安装了iOS 6.1 Simulator(它在首选项中可用)。 I also switched Base SDK to iOS 6.1 in project settings. 我还在项目设置中将Base SDK切换到iOS 6.1。

After all these manipulations the project with 6.1 base sdk runs in comp ability mode in iOS 7 Simulator. 在所有这些操作之后,具有6.1 base sdk的项目在iOS 7 Simulator中以comp comp模式运行。

From 1st february Apple will reject app built only for iOS6 or lower. 从2月1日起,Apple将拒绝仅针对iOS6或更低版本构建的应用程序。 Here is also the official communication from Apple. 这也是Apple的官方通讯 Better start building for iOS7. 最好开始为iOS7构建。

To clarify my statement: If you build for iOS6 or lower, apple will reject your app. 澄清我的陈述:如果您为iOS6或更低版本构建,Apple将拒绝您的应用。 If you build for iOS7 AND lower everything is fine, this means: 如果你为iOS7构建并降低一切都很好,这意味着:

  1. you must use xcode5 你必须使用xcode5
  2. you should deploy on iOS7 at least. 你应该至少在iOS7上部署。

The content of the Apple email is pretty clear at me Apple电子邮件的内容非常清楚

"Make sure your apps work seamlessly with the innovative technologies in iOS 7. Starting February 1, new apps and app updates submitted to the App Store must be built with Xcode 5 and iOS 7 SDK." “确保您的应用程序与iOS 7中的创新技术无缝协作。从2月1日开始,提交到App Store的新应用程序和应用程序更新必须使用Xcode 5和iOS 7 SDK构建。”

I currently have Xcode 4.6.3 and 5.0 installed. 我目前安装了Xcode 4.6.3和5.0。 I used the following bash script to link 5.0 to the SDKs in the old version: 我使用以下bash脚本将5.0链接到旧版本的SDK:

platforms_path="$1/Contents/Developer/Platforms";
if [ -d $platforms_path ]; then
    for platform in `ls $platforms_path`
    do
        sudo ln -sf $platforms_path/$platform/Developer/SDKs/* $(xcode-select --print-path)/Platforms/$platform/Developer/SDKs;
    done;
fi;

You just need to supply it with the path to the .app: 你只需要为它提供.app的路径:

./xcode.sh /Applications/Xcode-463.app

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

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