Xcode 5有一个首选项窗格,允许一个人下载iPhone 6.1模拟器,但我找不到一个地方,它允许下载iOS 6 SDK,因此不可能将活动SDK设置为iOS 6时,用Xcode 5开发。是否存在允许Xcode 5安装iOS 6 SDK的解决方案?
编辑:
既然Xcode 5已经普遍可用,并且允许你下载以前版本的SDK,那么变通方法应该不再是必要的了。
Xcode 5有一个首选项窗格,允许一个人下载iPhone 6.1模拟器,但我找不到一个地方,它允许下载iOS 6 SDK,因此不可能将活动SDK设置为iOS 6时,用Xcode 5开发。是否存在允许Xcode 5安装iOS 6 SDK的解决方案?
编辑:
既然Xcode 5已经普遍可用,并且允许你下载以前版本的SDK,那么变通方法应该不再是必要的了。
当前回答
Download Xcode 4.6.x from the Apple Dev Center: https://developer.apple.com/downloads/index.action Create a folder called Xcode4 within the Applications folder and drag-n-drop the downloaded dmg there. 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
其他回答
对我来说最简单的解决方法:
Locate an older SDK like for example "iPhoneOS6.1 sdk" in an older version of xcode for example. 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 Simple Copy the folder iPhoneOS6.X sdk and paste it in your xcode.app right click on your xcode.app in Applications folder. Go to Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ Just paste here.
关闭你的xcode应用程序,重新打开它。
要在模拟器上测试iOS 6中的应用程序: -在你的活动场景中选择iOS 6.0即可。
要在iOS 6中构建应用程序,那么你的应用程序的设计将是iOS 7 iPhone上的旧设计: —在“Targets - Base SDK”中选择“iOS6.1”
请注意:当你在你的目标中改变基础SDK时,iOS 7.0将不再可用来构建模拟器!
找到并下载旧的SDK。在这里可以找到旧的sdk。
我已经复制了xcode。app目录为Xcode_4.6.3.app。
现在你可以在两个xcode版本中进行测试和调试。你必须从相应的文件夹中运行它们,或者在桌面上创建快捷方式。从命令行构建时,将参数设置为iPhoneOS6.1而不是iPhoneOS7.0
这在Xcode5和iOS中非常有效。
进入Xcode5的SDK目录。它通常位于:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
向旧SDK添加一个符号链接,如下所示:
sudo ln -s /Applications/Xcode_4.6.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk iPhoneOS6.1.sdk
或者更准确地说,在命令行中,
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
Download Xcode 4.6.x from the Apple Dev Center: https://developer.apple.com/downloads/index.action Create a folder called Xcode4 within the Applications folder and drag-n-drop the downloaded dmg there. 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时,我宁愿保留以前的安装,而不是替换它们。这些都在我的安装文件夹里
所以/应用程序/ xcode /内容/开发/平台/ iPhoneOS。platform/Developer/ sdk包含不同的sdk。(取代Xcode。应用程序与正确的数字)复制以前的SDKS到
/应用程序/ Xcode 3.应用/内容/开发/平台/ iPhoneOS.platform /开发/ sdk
这是我复制后的文件夹。
现在重新启动xCode,你可以将以前版本的sdk设置为基础sdk。
为什么没有必要
引用Apple Documentaion
为了在Xcode项目中使用特定的SDK,在项目的构建设置中做两个选择。
选择一个部署目标。 这标识了软件可以在其上运行的最早的操作系统版本。 选择基础SDK 您的软件可以使用OS版本中提供的功能,包括与基本SDK对应的版本。默认情况下,Xcode将此设置为Xcode支持的最新操作系统。
规则是使用最新的基础SDK,并将部署目标设置为应用程序应该运行的最低版本
例如,你可以使用iOS 7作为基础sdk,并设置iOS 6作为部署目标。在iOS 6模拟器上运行以测试它在iOS 6上的工作方式。安装模拟器,如果模拟器列表不可用。
另外,您可以无条件使用iOS 6以上的功能。有条件地,你可以在支持以前版本的同时,为新更新的设备支持iOS 7的新功能。
这可以使用弱链接类、弱链接方法、函数和符号来实现
https://developer.apple.com/library/ios/documentation/developertools/conceptual/cross_development/Using/using.html#//apple_ref/doc/uid/20002000-SW3
弱连接
假设在Xcode中,你将部署目标(最低要求版本)设置为iOS6,而目标SDK(最大允许版本)设置为iOS7。在编译过程中,编译器会弱链接任何在iOS7中引入的接口,而强链接之前的接口。这将允许你的应用程序继续在iOS6上运行,但仍然可以利用更新的功能。
我目前已经安装了Xcode 4.6.3和5.0。我使用下面的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;
你只需要为它提供.app的路径:
./xcode.sh /Applications/Xcode-463.app