250

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?

EDIT:

Workarounds should no longer be necessary now that Xcode 5 is generally available and allows you to download previous versions of the SDK.

enter image description here

Ortwin Gentz
  • 48,409
  • 23
  • 127
  • 204
Tony
  • 30,345
  • 9
  • 45
  • 77
  • 41
    To take advantage of many improvements in Xcode 5, while still being able to build app for today's app store. – Tony Aug 24 '13 at 23:13
  • 61
    Hey maddy, the point about "embracing iOS 7 anyways" is totally not tied to the GA release. The decision and effort of redesigning an app's whole design language and UX to come in line with the flat design and re-designed iOS7 UI components is neither small, nor can come easily from a business & timing perspective. Building against SDK 6.1 will have iOS7 use the UI design language of iOS 6 and prior (for backwards support purposes). Thus it may be very well-warranted that we want to develop in Xcode 5 against the 6.1 SDK for some good time to come. – Marchy Sep 11 '13 at 18:34
  • 2
    hmmm maybe because he expects the SDK to be separated from the IDE, instead of one monolithic pile of code? – phreakhead Oct 17 '13 at 23:29
  • 1
    I am currently working with a client that is not ready to embrace the IOS7 UI changes, but can benefit from the Core Data migration improvements in XCode 5. So in this case, this is exactly what I want as well. – Droid Chris Nov 26 '13 at 15:29
  • One might think that Xcode, if not including SDK 6.1, would at least integrate it smoothly. But then there's [this problem](http://stackoverflow.com/a/19057537/1431728). – JohnK Jan 05 '14 at 21:08

15 Answers15

204

EDIT: Starting Feb 1, 2014, Apple will no longer accept pre-iOS7 apps for submission to 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.

See How to point Xcode to an old SDK so it can be used as a "Base 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.

The only trick is getting the old SDKs. 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.

SDKs can be found within the installer package at:

Xcode.app/Contents/Developer/Platforms/

Community
  • 1
  • 1
Rob Napier
  • 250,948
  • 34
  • 393
  • 528
  • do you need to remove the iOS 7 SDK when archiving to ensure that it builds with the iOS 6 SDK? – ohayon Sep 11 '13 at 16:48
  • For what it's worth, you need to copy the simulator SDKs too, and then be sure to run the simulator against the right version. – Jason Sep 19 '13 at 17:19
  • Agreed. The recent edit to this answer pointed people to the iPhoneOS SDKs. I've re-edited the answer to include all the SDKs (you'll want Mac SDKs if you develop for Mac). – Rob Napier Sep 19 '13 at 18:00
  • 6
    hi. this is close but not quite for me. the buttons look like iOS 6 but the view controller content still goes up behind the navigation bar when using a UINavigationController. any thoughts about how to get the iOS 6 behavior for that as well? – matt bezark Sep 21 '13 at 22:30
  • You can't get that. iOS 6 behavior is not available on iOS 7 (even for things built with iOS 6 originally). If it were, we wouldn't have had to all update our layouts to support ios 7. You'll have to make at least some ios7 calls to reconfigure the view controller. You should ask a new question if that's a problem. – Rob Napier Sep 22 '13 at 13:07
  • Could you tell if this makes iOS 7 simulator show UI elements like it does in iOS 6.x (or whichever you copy SDK from)? My recent observation doesn't confirm this: http://stackoverflow.com/a/18948081/1506363 – Nirav Bhatt Sep 22 '13 at 19:59
  • 2
    No; you'll only see this on the device. There is no iOS 6 compatibility mode in the iOS 7 simulator. If you want to see how it looks in the simulator, test on the iOS 6 simulator. – Rob Napier Sep 22 '13 at 22:51
  • This strategy doesn't seem to work for iOS 5 SDK. Any thoughts on why that might be the case? – Tony Sep 24 '13 at 16:53
  • I just tried this with an iOS 5 project and it seems to work. It even still seems to work with my 4.3 SDK. What problem are you seeing? – Rob Napier Sep 24 '13 at 22:41
  • @RobNapier when i install more than one iphoneOS platform SDKs (7.0, 6.1, 5.1 etc) the device i plug in is shown with the same name in as many rows as there are installed SDKs in the device selection pane. do you have this problem? is there a way to distinguish between them? – akaralar Sep 25 '13 at 22:35
  • 1
    Can I submit the app that is built with Xcode 5 and iOS 6 SDK to App Store? – hujunfeng Sep 26 '13 at 03:51
  • Yes; you get multiple copies. They appear to be in order, however. I haven't had any trouble submitting to App Store, but Apple can decide their own rules at any time. – Rob Napier Sep 26 '13 at 13:05
  • 1
    As long as the iPad 1 is still supported you can always assume Apple will accept 5.X iOS. It can't be upgraded. – ahwulf Oct 16 '13 at 13:20
  • Using 6.1 as the Base SDK, I cannot get the `.xib` to behave as it was compiled in Xcode 4.6: http://stackoverflow.com/questions/19509250/how-to-get-back-the-uibutton-border-in-ios-7? – ohho Oct 22 '13 at 06:52
  • @BasilBourque: ...if built in Xcode 5 using latest SDK: iOS 7 SDK – user523234 Feb 06 '14 at 15:44
  • @BasilBourque https://developer.apple.com/ios7/ "Starting February 1, new apps and app updates submitted to the App Store must be built with Xcode 5 and iOS 7 SDK." I don't speak for Apple, and their actual criteria may be different. I'm just reading what they published. – Rob Napier Feb 06 '14 at 17:21
60

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,952
  • 1
  • 19
  • 24
  • 2
    how and where did you download this ios6.1 sdk? I am looking for iOS 5 sdk to run against my Xcode 5. Can you either upload that or point in me where I can download it myself. Thank you – Sam B Sep 19 '13 at 20:36
  • Actually, I am having the old system also. so I taken this from older xcode. The same I tried for ios sdk 5 but as not much needed I not tried to get that out from. Also, if this answer seems good, I value your feedback in terms of + or -. Thank you. – AvtarSingh Suchariya Sep 19 '13 at 20:55
  • 1
    Hey Avtar, I downloaded your ios6 zip, unzipped it under the location path that you had listed, closed xcode 5 completely, relaunched it again and yet I still see only 7.0 as deployable target in drop down option. I assuming there are missing steps and there is more to it? – Sam B Sep 19 '13 at 20:58
  • The same is working for me. Just a question, did you added this into xcode app itself or created a symbolic link ? – AvtarSingh Suchariya Sep 19 '13 at 21:01
  • directly to app dir itself. – Sam B Sep 19 '13 at 21:02
  • Well, The same I did and it showing options from 4.3 to 7.0. But yes I installed all the simulator also. not sure that might effect. – AvtarSingh Suchariya Sep 19 '13 at 21:04
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/37689/discussion-between-avtarsingh-suchariya-and-sam-budda) – AvtarSingh Suchariya Sep 19 '13 at 21:05
  • another change I made, Build Setting > Architectures > standard (not 64) so list all the versions of Deployment Target. – AvtarSingh Suchariya Sep 19 '13 at 21:11
  • This is fantastic, thanks for your help. I downloaded XCode 4.6.3 from the developer website and just copied the iOS 6 SDK folder into XCode 5, worked first try. – n13 Oct 12 '13 at 07:59
  • this is relevant for users on XCode6 but still developing for iOS 6.1. Cheers! – chongzixin Sep 25 '14 at 01:50
34

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.
  2. Copy & put it into the Xcode 5 directory : /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs.

enter image description here

Then you can choose the SDK like below :

enter image description here

Hope this helps you.

Jason Lee
  • 3,112
  • 1
  • 30
  • 68
  • 2
    I did same but my GUI of app changes and it looks like iOS 7 GUI. I have choose iPhone Retina(4 inch 64-bit) simulator to run app. I am missing anything else after doing this. – python Sep 24 '13 at 12:56
20

Find and download old SDK. Older SDKs are found here.

I have copied the xcode.app directory as Xcode_4.6.3.app.

Now you can test and debug in both xcode versions. 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

This worked great for me in Xcode5 and iOS.

Go to into Xcode5's SDK dir. Its usually located at:

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

Add a symbolic link to the old SDK like this:

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
karim
  • 14,810
  • 7
  • 55
  • 92
  • We can use this option to test our app, but probably after feb 2014, any app built with prior iOS 7 sdk will not be accepted in app store! – karim Mar 16 '14 at 18:52
11

You can download the older SDK and install it in

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

unspokenblabber
  • 1,537
  • 1
  • 11
  • 18
  • I've done this (using download link in an earlier answer), and the iOS 6.1 sdk choice does show up in xcode 5 under Build Settings > Architectures > Base SDK. However, when I build and run on iOS 7 simulator (or iOS 7 device) it's *still* using iOS 7 UIKit buttons (not iOS 6 versions). If anyone has any suggestions as to why, I'd be grateful.... – Bill Patterson Sep 19 '13 at 21:48
  • If you have TimeMachine installed you can open the above path (in terminal type:open "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/" ) and restore the iOS6.1 SDK from there. – avance Oct 18 '13 at 19:30
11

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:

enter image description here

Smikey
  • 7,676
  • 3
  • 42
  • 74
  • This must have happened since xcode 5 came out of beta and is now a general release. Good to know, thanks Smikey – Tony Oct 15 '13 at 17:23
  • 5
    @Manni This is not the same as compiling against the old API. You are building using the new API for iOS 6. – oligofren Oct 22 '13 at 08:01
  • These options do not appear by default on Xcode 6 even if you've set an older target platform. – GilesDMiddleton Nov 28 '14 at 10:49
10
  • 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
autremoi
  • 261
  • 2
  • 7
10

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. 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 enter image description here
  2. 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.

enter image description here

  1. Close your xcode app and re-open it again.

To test an app in iOS 6 on your simulator: - Just choose iOS 6.0 in your active sheme. enter image description here

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

enter image description here

Just note : When you change the base SDK in your Targets, iOS 7.0 won't be available anymore for building on the simulator !

Daniel C.
  • 1,414
  • 1
  • 10
  • 5
9

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. So I have these in my installation Folder

enter image description here

So /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs Contain different sdks. (Replace Xcode.app with correct number) copy previous sdks to

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

Here is my folder after I copied one.

enter image description here

Now restart xCode and you can set previous versions of sdks as base sdk.

Why it is not necessary

Refering Apple Documentaion

To use a particular SDK for an Xcode project, make two selections in your project’s build settings.

  1. Choose a deployment target.

    This identifies the earliest OS version on which your software can run.

  2. Choose a base SDK

    Your software can use features available in OS versions up to and including the one corresponding to the base SDK. By default , Xcode sets this to the newest OS supported by Xcode.

Rule is Use latest as base SDK and set deployment target to the minimum version app supposed to run

For example you can use iOS 7 as base sdk and set iOS 6 as deployment target. Run on iOS 6 simulator to test how it works on iOS 6. Install simulator if not available with list of simulators.

enter image description here

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.

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

Weak Linking

Suppose in Xcode you set the deployment target (minimum required version) to iOS6 and the target SDK (maximum allowed version) to iOS7. During compilation, the compiler would weakly link any interfaces that were introduced in iOS7 while strongly linking earlier interfaces. This would allow your application to continue running on iOS6 but still take advantage of newer features when they are available.

Community
  • 1
  • 1
MadNik
  • 7,273
  • 2
  • 33
  • 37
4

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?" (currently points here) and mount the dmg.

Then in terminal, copy the SDK files over:

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.

nioq
  • 3,165
  • 1
  • 21
  • 17
3

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). If the new SDK doesn't cause some insurmountable problem, then why not build using it? Surely there are many improvements under the hood.

For example, I will much prefer to use Xcode 5 instead of 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.

Steven Lu
  • 36,733
  • 50
  • 179
  • 328
  • Reasons not to - Xcode 5 is pretty unstable at the moment. Crashing hourly for me. Also some weird positional issues and colour issues in some views (though not lots of work to fix) – Nick H247 Sep 20 '13 at 15:56
2

Linking the 6.1 SDK into Xcode 5 as described in the other answers is one step. 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.

As described in this answer it is also required to switch the UI into legacy mode on iOS 7:

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

Beware: This is an undocumented key and not recommended for App Store builds!

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]. Also there are subtle differences to a version built using 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.

Community
  • 1
  • 1
Ortwin Gentz
  • 48,409
  • 23
  • 127
  • 204
1

I downloaded XCode 4 and took iOS 6.1 SDK from it to the XCode 5 as described in other answers. Then I also installed iOS 6.1 Simulator (it was available in preferences). I also switched Base SDK to iOS 6.1 in project settings.

After all these manipulations the project with 6.1 base sdk runs in comp ability mode in iOS 7 Simulator.

OneSman7
  • 404
  • 4
  • 4
1

From 1st february Apple will reject app built only for iOS6 or lower. Here is also the official communication from Apple. Better start building for iOS7.

To clarify my statement: If you build for iOS6 or lower, apple will reject your app. If you build for iOS7 AND lower everything is fine, this means:

  1. you must use xcode5
  2. you should deploy on iOS7 at least.

The content of the Apple email is pretty clear at me

"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."

Andrea
  • 24,774
  • 10
  • 79
  • 121
  • Yes, but iOS 6 SDK works well with iOS 7, too. Some apps are really pain to be switched. – Aniruddh Jan 16 '14 at 20:50
  • I believe you are incorrect. Apple is requiring (a) Built by latest Xcode 5, and (b) *optimized* for iOS 7. See my comment on [Rob Napier’s answer](http://stackoverflow.com/a/18424373/642706) for links. – Basil Bourque Jan 18 '14 at 23:31
  • Some of us develop for Enterprise distribution and need to target older SDKs (and devices). Enterprise apps do not go through the Apple Review process and/or App Store, and this discussion is quite useful, remains relevant, and will continue to be relevant into the future. I understand your perspective, but it is not the only one. – Kevin OMara May 13 '14 at 22:13
  • You are totally right!!! I didn't thought about enterprise distribution. But don't forget that you can still deploy on iOS6 with the new Xcode just by setting the deployment target, without caring about ios7 optimization and review process. – Andrea May 14 '14 at 05:09
0

I currently have Xcode 4.6.3 and 5.0 installed. I used the following bash script to link 5.0 to the SDKs in the old version:

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:

./xcode.sh /Applications/Xcode-463.app
Wayne
  • 56,476
  • 13
  • 125
  • 118
  • Note that upgrading to 5.1 removed my 7.0.x SDK and replaced it with the 7.1 SDK. I have an old install of `Xcode5-DP6` that I was able to recover 7.0.x from, but this is a good reminder to backup the SDK dirs (or rename the app entirely) before upgrading to or installing the latest Xcode version. – Wayne Mar 19 '14 at 17:49