@@ -81,9 +81,17 @@ rsync \
81
81
--delete \
82
82
" $src_xcschemes " " $dest_xcschemes /"
83
83
84
+ if [[ $( uname) == " Darwin" ]]; then
85
+ is_macos=1
86
+ else
87
+ is_macos=0
88
+ fi
89
+
84
90
# 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
87
95
readonly cp_cmd=" cp -c"
88
96
else
89
97
readonly cp_cmd=" cp"
@@ -146,31 +154,37 @@ mkdir -p "$user_xcschmes"
146
154
$cp_cmd " $src_xcschememanagement " " $dest_xcschememanagement "
147
155
chmod u+w " $dest_xcschememanagement "
148
156
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
165
178
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 "
168
181
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
171
184
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
174
188
175
189
# Create folder structure in bazel-out to work around Xcode red generated files
176
190
if [[ -s " $src_generated_directories_filelist " ]]; then
0 commit comments