Skip to content

Commit c9e701d

Browse files
committed
Fix incremental_installer.sh when running on Linux
Signed-off-by: Brentley Jones <github@brentleyjones.com>
1 parent 649a55a commit c9e701d

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

xcodeproj/internal/templates/incremental_installer.sh

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,17 @@ rsync \
8181
--delete \
8282
"$src_xcschemes" "$dest_xcschemes/"
8383

84+
if [[ $(uname) == "Darwin" ]]; then
85+
is_macos=1
86+
else
87+
is_macos=0
88+
fi
89+
8490
# Resolve the copy command (can't use `cp -c` if the files are on different
85-
# filesystems)
86-
if [[ $(stat -f '%d' "$src_xcschemes") == $(stat -f '%d' "$dest_xcschemes") ]]; then
91+
# filesystems, or on Linux)
92+
if [[ $is_macos -eq 1 &&
93+
$(stat -f '%d' "$src_xcschemes") == $(stat -f '%d' "$dest_xcschemes") ]]
94+
then
8795
readonly cp_cmd="cp -c"
8896
else
8997
readonly cp_cmd="cp"
@@ -146,31 +154,37 @@ mkdir -p "$user_xcschmes"
146154
$cp_cmd "$src_xcschememanagement" "$dest_xcschememanagement"
147155
chmod u+w "$dest_xcschememanagement"
148156

149-
# Set desired `project.xcworkspace` data
150-
readonly workspace_data="$dest/project.xcworkspace/xcshareddata"
151-
readonly workspace_checks="$workspace_data/IDEWorkspaceChecks.plist"
152-
readonly workspace_settings="$workspace_data/WorkspaceSettings.xcsettings"
153-
readonly settings_files=(
154-
"$workspace_checks"
155-
"$workspace_settings"
156-
)
157-
158-
mkdir -p "$workspace_data"
159-
for file in "${settings_files[@]}"; do
160-
if [[ ! -f $file ]]; then
161-
# Create an empty plist
162-
echo "{}" | plutil -convert xml1 -o "$file" -
163-
fi
164-
done
157+
# Even though we can generate a project on Linux, it can never run on Linux.
158+
# And since it has absolute paths, the generated project can't be copied to a
159+
# machine and still work. Given that, and since `plutil` doesn't exist on Linux,
160+
# we only run the following commands on macOS.
161+
if [[ $is_macos -eq 1 ]]; then
162+
# Set desired `project.xcworkspace` data
163+
readonly workspace_data="$dest/project.xcworkspace/xcshareddata"
164+
readonly workspace_checks="$workspace_data/IDEWorkspaceChecks.plist"
165+
readonly workspace_settings="$workspace_data/WorkspaceSettings.xcsettings"
166+
readonly settings_files=(
167+
"$workspace_checks"
168+
"$workspace_settings"
169+
)
170+
171+
mkdir -p "$workspace_data"
172+
for file in "${settings_files[@]}"; do
173+
if [[ ! -f $file ]]; then
174+
# Create an empty plist
175+
echo "{}" | plutil -convert xml1 -o "$file" -
176+
fi
177+
done
165178

166-
# - Prevent Xcode from doing work that slows down startup
167-
plutil -replace IDEDidComputeMac32BitWarning -bool true "$workspace_checks"
179+
# - Prevent Xcode from doing work that slows down startup
180+
plutil -replace IDEDidComputeMac32BitWarning -bool true "$workspace_checks"
168181

169-
# - Configure the project to use Xcode's new build system.
170-
plutil -remove BuildSystemType "$workspace_settings" > /dev/null || true
182+
# - Configure the project to use Xcode's new build system.
183+
plutil -remove BuildSystemType "$workspace_settings" > /dev/null || true
171184

172-
# - Prevent Xcode from prompting the user to autocreate schemes for all targets
173-
plutil -replace IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded -bool false "$workspace_settings"
185+
# - Prevent Xcode from prompting the user to autocreate schemes for all targets
186+
plutil -replace IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded -bool false "$workspace_settings"
187+
fi
174188

175189
# Create folder structure in bazel-out to work around Xcode red generated files
176190
if [[ -s "$src_generated_directories_filelist" ]]; then

0 commit comments

Comments
 (0)