Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to point Xcode to an old SDK so it can be used as a "Base SDK"?

My Mac's Setup:

Volume A:
OS X 10.8
Xcode 4.5 or later - 10.6 SDK IS NOT available as Base SDK

Volume B:
OS X 10.7
Xcode 4.3.3 - 10.6 SDK IS available as Base SDK

Volume C:
OS X 10.6
Xcode 4.2 - 10.6 SDK IS available as Base SDK


On Volume A, I have installed Xcode 4.5, which does not include the 10.6 SDK as an available "Base SDK" in my Build Targets' Build Settings.

I have a separate 10.6 volume and 10.7 volume on this hard drive - both of which have Xcode installed, and both of which allow me to select the 10.6 SDK as a Base SDK in my Xcode Build Targets' Build Settings.

I know that I have the 10.6 SDK installed on Volume C (at /Developer/SDKs from an older Xcode installation).

How can I point Xcode on Volume A to the 10.6 SDK which lives on Volume C?

like image 458
Todd Ditchendorf Avatar asked Jul 11 '12 02:07

Todd Ditchendorf


People also ask

How do I change base SDK in Xcode?

Is there a way to do this? You can build an app that runs on older versions of iOS by selecting the appropriate deployment target (no earlier than iOS 8). You must use the 12.1 Base SDK. But selecting a deployment target to an earlier version causes the base SDK to also go to an earlier version.

Where are Xcode SDKs stored?

Newer Xcode versions have the SDKs inside the Xcode. app bundle, e.g. from the command line. If you have installed the "Command Line Tools" (Xcode Preferences -> Downloads -> Components) then compiling without "-syslibroot" should be equivalent to compiling against the latest SDK.

Can I delete Macos SDK?

No, you're fine to delete them. Each SDK is self contained.


2 Answers

You'll need to add a symlink to the old SDK (this is generally easier than copying).

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ln -s /path/to/old/SDK . 

This works fine back to 10.5. Beyond that things get a little more complicated...

While there's no promise in future versions of Xcode that this will be supported, I've chatted with the Xcode team about it and they don't seem keen on changing it anytime soon.

Personally I often keep /path/to/old/SDK in a top-level directory called /SDKs. That way every time I upgrade it's easy to fix everything up.

EDIT: I have a fix-xcode script that simplifies re-applying this fix every time Xcode upgrades.


UPDATE: In modern versions of Xcode (7.3+) to use older SDKs edit MinimumSDKVersion here:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist 
like image 77
Rob Napier Avatar answered Oct 03 '22 13:10

Rob Napier


Wrong approach. You don't "point" Xcode at an SDK. Instead you will have better luck copying the SDK into the appropriate "SDKs" folder for the Xcode installation. In modern Xcode installations this is usually:

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

Copy the SDK in there, quit and restart Xcode and see what you find.

(reading the other answer here I think that symbolic linking might be an option if you are dead-set on keeping the original SDK elsewhere)

like image 43
danielpunkass Avatar answered Oct 03 '22 12:10

danielpunkass