-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxcode.sh
More file actions
executable file
·97 lines (60 loc) · 2.03 KB
/
xcode.sh
File metadata and controls
executable file
·97 lines (60 loc) · 2.03 KB
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
91
92
93
94
95
96
97
#!/bin/bash
# shellcheck source=/dev/null
declare current_dir &&
current_dir="$(dirname "${BASH_SOURCE[0]}")" &&
cd "${current_dir}" &&
source "$HOME/set-me-up/dotfiles/utilities/utilities.sh"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
agree_with_xcode_license() {
# Automatically agree to the terms of the `Xcode` license.
# https://github.com/alrra/dotfiles/issues/10
sudo xcodebuild -license accept &>/dev/null
}
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.
until is_xcode_installed; do
sleep 5
done
}
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.
until are_xcode_command_line_tools_installed; do
sleep 5
done
}
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
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
main() {
# Check if OS is macOS
if ! is_macos; then
error "This script is only for macOS!"
return 1
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
install_xcode_command_line_tools
install_xcode
set_xcode_developer_directory
agree_with_xcode_license
}
main