-
-
Save hlung/6806651 to your computer and use it in GitHub Desktop.
More verbose print and check to process only *.platform folders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# fix-xcode-sdk | |
# Rob Napier <[email protected]> | |
# Forked by Thongchai Kolyutsakul <[email protected]> | |
# (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