Skip to content

Instantly share code, notes, and snippets.

@hlung
Forked from rnapier/fix-xcode
Last active December 24, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/6806651 to your computer and use it in GitHub Desktop.
Save hlung/6806651 to your computer and use it in GitHub Desktop.
More verbose print and check to process only *.platform folders.
#!/usr/bin/python
# fix-xcode-sdk
# Rob Napier <robnapier@gmail.com>
# Forked by Thongchai Kolyutsakul <thongchaikol@gmail.com>
# (https://gist.github.com/hlung/6806651)
# 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-sdk.
#
# Example:
# ./fix-xcode-sdk <-- default to /Applications/Xcode.app, or...
# ./fix-xcode-sdk /Applications/Xcode_another.app <-- specify which Xcode to link
import argparse
import subprocess
import os
# source_path is where the ".platform" folders are
source_path = os.path.expanduser("~")+"/SDKs" # "~/SDKs" doesn't work in python!
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"
print "Creating symbolic links from: " + source_path
print " to Xcode path: " + dest_path
print ""
for platform in os.listdir(source_path):
if platform.endswith(".platform"): # avoid reading other files than *.platform
# create symbolic link
subprocess.call("sudo ln -sf %(source_path)s/%(platform)s/* %(dest_path)s/Platforms/%(platform)s/Developer/SDKs" % locals(), shell=True)
# print the progress
# get file list in the platform folder and filter out files like .DS_Store
fileList = os.listdir(source_path+"/"+platform)
fileList = [i for i in fileList if not i.startswith(".")]
print " linked \"" + platform + "\": "+ ' '.join(fileList)
print ""
print "*** Completed! ***"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment