-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxcode_plugins_update.sh
executable file
·74 lines (49 loc) · 1.79 KB
/
xcode_plugins_update.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /bin/bash
XCODE_MAS_URL="https://itunes.apple.com/fr/app/xcode/id497799835"
# Search for Xcode
OPEN_CMD_PATH=`which open`
XCODE_SELECT=`which xcode-select`
if [ -n "$XCODE_SELECT" ]; then
XCODE_DEV_DIR=`$XCODE_SELECT -p`
fi
# Exit if XCode or its command line tools are not installed
if [[ -z "$XCODE_SELECT" || -z "$XCODE_DEV_DIR" ]]; then
echo "Xcode Command line Tools not found"
if [ -n "$OPEN_CMD_PATH" ]; then
echo "Your default browser should open with Xcode download page"
$OPEN_CMD_PATH $XCODE_MAS_URL
fi
echo "Exiting..."
exit
fi
# Substring to .app location
DEV_DIR_RELATIVE_TO_XCODE=${XCODE_DEV_DIR#*.app}
XCODE_APP_PATH=${XCODE_DEV_DIR:0:${#XCODE_DEV_DIR}-${#DEV_DIR_RELATIVE_TO_XCODE}}
if [ -z "$XCODE_APP_PATH" ]; then
echo "unnable to find the Xcode.app location, Exiting..."
exit
fi
echo "Found Xcode at $XCODE_APP_PATH"
# Getting Xcode UUID
XCODE_INFO_RELATIVE_PATH="Contents/Info"
XCODE_UUID_KEY="DVTPlugInCompatibilityUUID"
XCODE_UUID=`defaults read $XCODE_APP_PATH/$XCODE_INFO_RELATIVE_PATH $XCODE_UUID_KEY`
if [ -z "$XCODE_UUID" ]; then
echo "Unnable to find the Xcode UUID, Exiting..."
exit
fi
echo "With UUID: "$XCODE_UUID
# Updating Plugins Info file
XCODE_USER_PLUGINS_DIR=~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins
XCODE_PLUGIN_COMPATIBILITY_ARRAY="DVTPlugInCompatibilityUUIDs"
for PLUGIN_INFO in "$XCODE_USER_PLUGINS_DIR"/*
do
printf "Updating: "${PLUGIN_INFO#$XCODE_USER_PLUGINS_DIR/}
PLUGIN_XCODE_UUID=`defaults read "$PLUGIN_INFO/Contents/Info" $XCODE_PLUGIN_COMPATIBILITY_ARRAY | grep $XCODE_UUID`
if [ -z "$PLUGIN_XCODE_UUID" ]; then
defaults write "$PLUGIN_INFO/Contents/Info" $XCODE_PLUGIN_COMPATIBILITY_ARRAY -array-add $XCODE_UUID;
echo "\t\t[OK]"
else
echo "\t\t[UP TO DATE]"
fi
done