This is a question out of interest, so please be as informative as possible with your answer.
I recently updated Xcode to 4.5 and lost access to iOS SDK 5.1. Using the method described in several SO posts (use an image from previous Xcode installer) I added the iOS SDK 5.1 again.
The environments I want to support with my apps are iPhone 3GS, iPhone 4, iPhone 4S and iPhone 5. Obviously with iOS SDK 5.1 and 6.0. What are the recommended build settings for these requirements?
Right now I set the Deployment Target on 5.1, Base SDK on 6.0, architectures on armv7 and armv7s. Is this correct?
Now, I believe iOS SDK 5.1 is not compiled for armv7s (iPhone 5 architecture). How do I make sure that the code compiled for iOS 6.0 also works on iPhones < 5? Right now I’m getting linker errors ld: file is universal (4 slices) but does not contain a(n) armv7s slice pointing to the iOS 5.1 SDK, when not checking Build For Active Architectures Only. How do I make sure that, when releasing to the App Store, the app will still run on iOS SDK 5.1. It appears to be compiling for armv7s in combination with iOS 5.1 — which won’t work.
Any help is greatly appreciated.
You didn’t need to download SDK 5.1 at all. SDK 6.0 includes every libraries and headers SDK 5.1 includes, plus the added libraries and headers of iOS6.
Be sure to understand the difference between the version of the SDK, the versions of iOS your app will be compatible with, and the architectures you build your app for.
Compiling with SDK 6.0 does not mean that your app will only work on iOS6; it mean your app will be able to run on iOS from the version you set in
IOS_DEPLOYMENT_TARGETto the version corresponding to the SDK, namely 6.0.So if you want your app to be compatible with iOS 5.1 and above, you still compile it using Base SDK 6.0 and don’t need SDK 5.1 at all: you just have to set the
Deployment Targetto 5.1 and theBase SDKon 6.0 (as you said in your question), so there is nowhere you need the SDK 5.1 for that, which is useless for compiling for iOS6, iPhone5 and armv7s anyway (it does not contains the necessary headers, libraries and architectures, that’s why the SDK 6.0 has been released and is necessary).Using an old SDK like 5.1 (you downloaded separately) with latest version of Xcode will probably lead you to problems, and will more importantly not allow you to compile your app for iOS versions higher than the version of the SDK (in your case 5.1). So do use SDK 6.0, even if you want your app to be compatible starting iOS 5.1.
For more information on the difference between the version of the SDK you use (Base SDK), the Deployment Target, and the supported iOS versions and architectures for your app, read the SDK Compatibility Guide in Apple documentation that explains it all in great details.