Skip to content

Instantly share code, notes, and snippets.

@rnapier
Last active June 19, 2026 17:26
Show Gist options
  • Select an option

  • Save rnapier/3370649 to your computer and use it in GitHub Desktop.

Select an option

Save rnapier/3370649 to your computer and use it in GitHub Desktop.
Links Xcode SDKs from the /SDKs directory (which you maintain yourself)
#!/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)
@mayoralito

Copy link
Copy Markdown

+1 Thanks!

@hlung

hlung commented Oct 3, 2013

Copy link
Copy Markdown

Nice!

@LeeSanghoon

Copy link
Copy Markdown

+1

@Alelelex

Alelelex commented Oct 8, 2013

Copy link
Copy Markdown

+1 Thanks

@link82

link82 commented Nov 6, 2013

Copy link
Copy Markdown

+1 Thank you!!

@lwburk

lwburk commented Nov 15, 2013

Copy link
Copy Markdown

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

@dacaiguoguogmail

Copy link
Copy Markdown

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

@rezwits

rezwits commented Apr 13, 2014

Copy link
Copy Markdown

Thanks

@enthuCoder

Copy link
Copy Markdown

Sweet!! +1

@agirault

Copy link
Copy Markdown

I get ld: library not found for -lcrt1.10.6.o when trying to compile using MacOSX10.6.sdk, any known solution?

@gblazex

gblazex commented Apr 3, 2016

Copy link
Copy Markdown

Modern versions of Xcode (7.3+) need you to edit the MinimumSDKVersion in this file to use older SDKs:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist

@KyNorthstar

Copy link
Copy Markdown
Traceback (most recent call last):
  File "fix-xcode", line 33, in <module>
    for platform in os.listdir(source_path):
OSError: [Errno 2] No such file or directory: '/SDKs'
  • macOS
    • 10.11.6
  • Xcode
    • 7.3.1
    • 8.0 Beta 6 (8A218a)
    • 8.0 GM (8S201h)

@jpmhouston

Copy link
Copy Markdown

Included on this page are commands to use for altering the Info.plist. Integration into the script should be straightforward, hmm, maybe except for parsing the version number out of the SDK path.

@macfanr

macfanr commented Sep 24, 2020

Copy link
Copy Markdown

This not work for xcode12

@startergo

startergo commented Oct 31, 2024

Copy link
Copy Markdown

@rnapier You might want to change :

#!/usr/bin/python

to

#!/usr/bin/env python3

As there is no more python integrated with the macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment