4

I have a new version of Xcode. I have an iOS device with a new version of iOS installed on it.

I want to build my app with the old iOS SDK, using the new version of Xcode.

How?

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • 1
    Why do you think this is needed? – rmaddy Jun 21 '13 at 22:11
  • You can build projects with a newer SDK and deploy them to an older version of iOS. Just set the “deployment target” of your target to the iOS version you want to support. – rob mayoff Jun 21 '13 at 23:04
  • @rmaddy - If your app doesn't work right on a new version of iOS yet, but you want to test and build your app in the new environment. – Aaron Brager Jun 21 '13 at 23:40
  • Still not needed. I can use Xcode 4.6.x to build and test my iOS 6.1 app on a device with iOS 7. No need to load the 6.1 SDK into Xcode 5 for this. – rmaddy Jun 21 '13 at 23:46
  • @robmayoff - Setting the deployment target isn't the same as building against an older SDK. That approach will not let you test a version of your app built for a lower version than the device is running. – Aaron Brager Jun 21 '13 at 23:47
  • @rmaddy - I don't think you can build onto an iOS 7 device from Xcode 4. I'd be happy to be corrected on that though. – Aaron Brager Jun 21 '13 at 23:53
  • @AaronBrager I made my statement because I've done exactly what I stated. Run Xcode 5, connect your iOS 7 device. Build and run some simple test app onto the device. Once it all works, close Xcode 5 and run Xcode 4.6. Xcode 4.6 should now recognize your iOS 7 device just fine. – rmaddy Jun 22 '13 at 00:45
  • rmaddy's method didn't work for me and our project. – Léo Natan Jun 27 '13 at 06:09
  • Don't do it. Apple don't fix any Xcode bugs with the older SDK that you copy in. So there's no guarantee your builds will be correct or reliable. You'll spend hours chasing 'phantom' bugs caused by SDK incompatibilities, too. It's irresponsible to ship builds made this way to your customers. – uliwitness Aug 04 '13 at 22:39
  • See http://stackoverflow.com/questions/18423896/is-it-possible-to-install-ios-6-sdk-on-xcode-5/18424373#18424373 – Rob Napier Sep 21 '13 at 14:58
  • @RobNapier It's funny that the answer in that question is upvoted to 37, and my nearly identical answer here is downvoted & deleted in favor of Chris Hanson's "answer" not do it it. – Aaron Brager Sep 23 '13 at 15:07

3 Answers3

27

You don't; the contents of the Xcode.app bundle should not be modified.

Any particular release of Xcode includes the SDKs against which it was qualified, and using any other SDK with it is unsupported.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
  • unsupported != impossible – Aaron Brager Jul 18 '13 at 19:50
  • 3
    Unsupported means it may break at any time, it may cause Xcode to behave unexpectedly, and the code generated by compiling against that SDK cannot be relied upon because the headers in the SDK were not necessarily used when qualifying the compiler included in the Xcode release in question. – Chris Hanson Aug 04 '13 at 22:09
  • Previous versions of Xcode, with the SDKs they're qualified with, should be available on http://developer.apple.com – millenomi Aug 04 '13 at 22:14
  • 2
    You should take Chris' answer on this subject as authoritative. He knows what he's talking about. – NSResponder Aug 04 '13 at 23:06
  • 1
    I’m not sure I have a huge amount of sympathy for either the OP or for @ChrisHanson here. The user’s choice of compiler shouldn’t really be tied to a specific set of SDKs like this. Apple doesn’t “qualify” Intel’s compiler, right? – al45tair Aug 05 '13 at 07:54
  • Aside from my answer, there's no way to test an iOS 6 build of my app on my iOS 7 device. If I anticipate a few more updates to my app before the release of iOS 7, I should be able to test how this app works on iOS 7, because when it's released, users will be running it on iOS 7. I don't know why @rmaddy's solution (in the question comments) works for him, but it doesn't work for anyone else I know. So, I'd rather do some testing with an unsupported configuration than do no testing at all. – Aaron Brager Aug 05 '13 at 14:18
  • @aaron-brager, the best thing to do here is to file a bug asking for exactly that (i.e. “please let me run/test apps built with a released Xcode and SDK on unreleased beta versions of iOS”). – clarkcox3 Sep 05 '13 at 00:20
  • 1
    BTW, I've opened Radar 15048179 (Detect incorrect SDK usage) to address a key requirement for the original question. The current Apple recommendation of using Deployment Target is very dangerous. If you use newer features, you'll get no warnings; just a crash when that code runs on an older OS. Third-party tools like Deploymate try to work around this Xcode limitation, but there is no safer approach than building with the actual target SDK. The likelihood that a compiler change will impact the old SDK is tiny compared to the likelihood that you'll make an SDK-usage mistake. – Rob Napier Sep 21 '13 at 15:14
  • 1
    I've come by to talk about this at WWDC in 2012 and 2013. So far, in person, no one on the Xcode team has suggested a way to make the current Apple recommendation safe for production code. Just realized I've now opened two radars on this; my original is 11985733. There's been no response except "Duplicate of 7184689 (Open)." Sorry for duping again. – Rob Napier Sep 21 '13 at 15:25
1

I was also running the same problem when I updated to xcode 5 it removed older sdk. But I taken the copy of older SDK from another computer and the same you can download from following link.

http://www.4shared.com/zip/NlPgsxz6/iPhoneOS61sdk.html
(www.4shared.com test account 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.

But this might again removed by Xcode if you update 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.

Another change I made, Build Setting > Architectures > standard (not 64) so list all the versions of Deployment Target

No need to download the zip if you only wanted to change the deployment target.

Here are some screenshots. enter image description here enter image description here

AvtarSingh Suchariya
  • 1,992
  • 1
  • 20
  • 25
  • 1
    Ok. How to submit such project to Apple for review? – Pavel Sep 26 '13 at 08:32
  • There is an organizer. You will find that option in Menu > Window > Organizer. It is responsible to submit the app to app store. Before that you need to prepare the build via Menu > Product > Archive. This option will only be enable if you have selected the device from Top Left Corner. – AvtarSingh Suchariya Sep 26 '13 at 08:53
  • I mean how to submit such app to Apple :) The app that is built in Xcode 5 with an old SDK (that is not a part of Xcode 5). – Pavel Sep 26 '13 at 08:55
  • That also can be submitted with xcode 5 only, just need to select the base/deployment sdk & target sdk. and that will submit perfectly. Not sure whether apple approve that or not. but submission can be done perfectly. – AvtarSingh Suchariya Sep 26 '13 at 09:44
-8

This answer is incorrect and its use is unsupported by Xcode. I am just leaving it here for historical reasons.


1. Copy the SDK from old Xcode to new Xcode

  1. Open your Applications folder.
  2. Right-click on the old version of Xcode and select Show Package Contents.
  3. Navigate to Contents -> Developer -> Platforms -> iPhoneOS.platform -> Developer -> SDKs.
  4. In a new window, open the same folder inside the new version of Xcode.
  5. Copy the SDK you want from old to new.
  6. If the new version of Xcode is running, you'll need to restart it now.

2. Set your SDK when building

In your project settings, select the target you're building on the left. Then select Build Settings, then Base SDK. You should now see two versions of the SDK. Select the SDK you'd like to build against.

Community
  • 1
  • 1
Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • Congratulations on solving your own problem within a minute! I have to wonder if this method still works with Xcode 4, since the application package is code signed. Or maybe the code signing process skips the "`Developer`" directory hidden within the application package? – Michael Dautermann Jun 21 '13 at 22:08
  • It still works with Xcode 4. I don't think the code signing affects bundled resources in the app. – Aaron Brager Jun 21 '13 at 23:54
  • 1
    Why is this voted down? This is the correct answer, and it works with Xcode 5. It provides a solution to something Apple does not allow (debugging iOS 6.1 SDK app on iOS7 device). – Léo Natan Jun 27 '13 at 06:08
  • 4
    This is not the correct answer; the correct answer is not to do it, because it is unsupported and unreliable. – Chris Hanson Aug 04 '13 at 22:10
  • It’s nothing to do with “NDA Apple crap”. @ChrisHanson (who works for Apple) is giving the official line — that you shouldn’t do this because it’s unsupported — which is fair enough. Given that you probably don’t need to do this (you can install Xcode.app side-by-side with older versions), it’s certainly best avoided. – al45tair Aug 05 '13 at 07:59
  • 1
    Asking question and answering it within 60 seconds with the prepared answered. That's sad. – Rafał Augustyniak Dec 01 '16 at 22:33
  • 1
    It's not "sad", it's "[explicitly encouraged](https://stackoverflow.blog/2011/07/its-ok-to-ask-and-answer-your-own-questions/)". – Aaron Brager Dec 04 '16 at 06:36
  • @RafałAugustyniak Please see the comment posted by Aaron Brager. Self answering is encouraged. – Modus Tollens Dec 04 '16 at 06:49