Skip to content

Instantly share code, notes, and snippets.

@antons
Last active May 4, 2016 20:04
Show Gist options
  • Save antons/4f13afa10cf1966485cd to your computer and use it in GitHub Desktop.
Save antons/4f13afa10cf1966485cd to your computer and use it in GitHub Desktop.
Script to make all your Xcode plugins “compatible” with currently selected version of Xcode.
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
xcode-plugin-add-compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
xcode-plugin-has-compatibility() {
$PLIST_BUDDY -c 'Print DVTPlugInCompatibilityUUIDs' \
"$1/Contents/Info.plist"|grep -q "$2"
return $?
}
xcode-plugin-update() {
# Save original path to restore it after script is done.
ORIGINAL_PATH="$PWD"
# Read the compatibility ID from the currently selected version of Xcode.
XCODE_INFO_PLIST="$(xcode-select -p)"/../Info.plist
ID=$("$PLIST_BUDDY" -c 'Print DVTPlugInCompatibilityUUID' "$XCODE_INFO_PLIST")
# Get human readable version info from Xcode for logging.
XCODE_VERSION_PLIST="$(xcode-select -p)"/../version.plist
XCODE_VERSION=$(printf '%s (%s)' $("$PLIST_BUDDY" -c 'Print CFBundleShortVersionString' "$XCODE_VERSION_PLIST") $("$PLIST_BUDDY" -c 'Print ProductBuildVersion' "$XCODE_VERSION_PLIST"))
# Go to plugin directory.
cd "$HOME/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
# Update code is taken from this script: https://gist.github.com/neonichu/9487584.
for file in `ls -d *`
do
if `xcode-plugin-has-compatibility "$file" $ID`
then
true
else
echo "Plugin $file is now compatible with Xcode $XCODE_VERSION"
xcode-plugin-add-compatibility "$file" $ID
fi
done
# Restore original path.
cd "$ORIGINAL_PATH"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment