public
Last active

Links Xcode SDKs from the /SDKs directory (which you maintain yourself)

  • Download Gist
fix-xcode
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#!/usr/bin/python
 
# fix-xcode
# Rob Napier <robnapier@gmail.com>
 
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs:
# MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk MacOSX10.7.sdk MacOSX10.8.sdk
#
# After upgrading Xcode, just run fix-xcode.
 
import argparse
import subprocess
import os
 
source_path = "/SDKs"
 
parser = argparse.ArgumentParser()
parser.add_argument('xcodePath', help='path to Xcode', nargs='?')
args = parser.parse_args()
 
if args.xcodePath:
dest_path = args.xcodePath
else:
dest_path = subprocess.check_output(["xcode-select", "--print-path"]).rstrip()
 
if not dest_path.endswith("/Contents/Developer"):
dest_path += "/Contents/Developer"
 
for platform in os.listdir(source_path):
subprocess.call("sudo ln -sf %(source_path)s/%(platform)s/* %(dest_path)s/Platforms/%(platform)s/Developer/SDKs" % locals(), shell=True)

This is great. I currently have both 4.6.3 and 5.0 installed. I used the following 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

ln: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS6.1.sdk/Developer/SDKs: No such file or directory
why this error?
xcode 5

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.