forked from alrra/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xcode.sh
executable file
·90 lines (58 loc) · 2.06 KB
/
xcode.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "../../utils.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
agree_with_xcode_licence() {
# Automatically agree to the terms of the `Xcode` license.
# https://github.com/alrra/dotfiles/issues/10
sudo xcodebuild -license accept &> /dev/null
print_result $? "Agree to the terms of the Xcode licence"
}
are_xcode_command_line_tools_installed() {
xcode-select --print-path &> /dev/null
}
install_xcode() {
# If necessary, prompt user to install `Xcode`.
if ! is_xcode_installed; then
open "macappstores://itunes.apple.com/en/app/xcode/id497799835"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Wait until `Xcode` is installed.
execute \
"until is_xcode_installed; do \
sleep 5; \
done" \
"Install Xcode.app"
}
install_xcode_command_line_tools() {
# If necessary, prompt user to install
# the `Xcode Command Line Tools`.
xcode-select --install &> /dev/null
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Wait until the `Xcode Command Line Tools` are installed.
execute \
"until are_xcode_command_line_tools_installed; do \
sleep 5; \
done" \
"Install Xcode Command Line Tools"
}
is_xcode_installed() {
[ -d "/Applications/Xcode.app" ]
}
set_xcode_developer_directory() {
# Point the `xcode-select` developer directory to
# the appropriate directory from within `Xcode.app`.
#
# https://github.com/alrra/dotfiles/issues/13
sudo xcode-select -switch "/Applications/Xcode.app/Contents/Developer" &> /dev/null
print_result $? "Make 'xcode-select' developer directory point to the appropriate directory from within Xcode.app"
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
main() {
print_in_purple " Xcode\n\n"
install_xcode_command_line_tools
install_xcode
set_xcode_developer_directory
agree_with_xcode_licence
}
main