-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathupdate_uuids.sh
executable file
·41 lines (32 loc) · 1.09 KB
/
update_uuids.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Lists all UUIDs of installed Xcodes and add them to the plugin plist file
DEST="`pwd`/SYXcodeIconVersion/Info.plist"
# add UUIDs of all present Xcode
for x in /Applications/Xcode*.app/Contents/Info.plist; do
UUID=`defaults read $x DVTPlugInCompatibilityUUID`
echo "Adding $UUID..."
defaults write $DEST DVTPlugInCompatibilityUUIDs -array-add $UUID
done
# remove duplicates
UUIDs=()
STOP=0
while [ $STOP -eq 0 ]; do
UUID=`/usr/libexec/PlistBuddy -c "Print :DVTPlugInCompatibilityUUIDs:${#UUIDs[@]}" $DEST 2>/dev/null`
if [ $? -eq 0 ]; then
UUIDs+=($UUID)
else
STOP=1
fi
done
echo "Found ${#UUIDs[@]} items"
# keep unique items, ordered
# http://stackoverflow.com/a/30377684/1439489
UUIDs=($(tr ' ' '\n' <<<"${UUIDs[@]}" | awk '!u[$0]++' | tr '\n' ' '))
echo "Removed duplicates, ${#UUIDs[@]} items remaining"
# remove old items
/usr/libexec/PlistBuddy -c "Delete :DVTPlugInCompatibilityUUIDs" $DEST
# add unique items
for UUID in "${UUIDs[@]}"; do
defaults write $DEST DVTPlugInCompatibilityUUIDs -array-add $UUID
done
plutil -convert xml1 -i $DEST -o $DEST