Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save p4checo/3d706fa03edc368074c1 to your computer and use it in GitHub Desktop.
Save p4checo/3d706fa03edc368074c1 to your computer and use it in GitHub Desktop.
update_Xcode_Plug-ins_CompatibilityUUID
#!/bin/bash
# based on (buggy on zsh)
#find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID
OLD_IFS=$IFS
IFS=$'\n'
BETA=""
while [ $# -gt 0 ]
do
case "$1" in
-beta|-b)
BETA="-beta";;
-help|-h)
echo >&2 "usage: $0 [-beta|-b]"
exit 1;;
*) break;; # terminate while loop
esac
shift
done
XCODE_VERSION=$(defaults read /Applications/Xcode$BETA.app/Contents/Info.plist CFBundleShortVersionString)
XCODE_PLUGIN_UUID=$(defaults read /Applications/Xcode$BETA.app/Contents/Info.plist DVTPlugInCompatibilityUUID)
PLUGIN_PLISTS=$(find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3)
echo "Updating Xcode$BETA $XCODE_VERSION Plug-ins with \`DVTPlugInCompatibilityUUIDs\` \""$XCODE_PLUGIN_UUID"\"..."
for plist in $PLUGIN_PLISTS
do
PLUGIN_HAS_UUID=$(defaults read "$plist" DVTPlugInCompatibilityUUIDs | grep $XCODE_PLUGIN_UUID)
if [[ $PLUGIN_HAS_UUID != "" ]]; then
echo "Skipped \""$plist"\""
else
defaults write "$plist" DVTPlugInCompatibilityUUIDs -array-add $XCODE_PLUGIN_UUID
plutil -convert xml1 "$plist"
echo "Updated \""$plist"\""
fi
done
echo "Resetting Xcode$BETA \`DVTPlugInManagerNonApplePlugIns-Xcode-"$XCODE_VERSION"\`..."
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-$XCODE_VERSION
echo "Done 🎉"
IFS=$OLD_IFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment