Skip to content

Commit 769f31f

Browse files
committed
Merge pull request #21 from godrei/xcpretty
xcpretty
2 parents 4dff30e + 4f3ade9 commit 769f31f

File tree

3 files changed

+77
-57
lines changed

3 files changed

+77
-57
lines changed

bitrise.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ workflows:
3030
inputs:
3131
- is_force_code_sign: "no"
3232
- is_clean_build: "no"
33-
- build_tool: xctool
3433
- workdir: $PROJECT_WORKDIR
34+
- output_tool: xcpretty
3535
# - configuration: Debug
3636
- script:
3737
title: Output (generated by the Step) tests

step.sh

Lines changed: 69 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44

55
set -e
66

7-
87
#
98
# Detect Xcode major version
109
xcode_major_version=""
@@ -45,14 +44,28 @@ if [ ! -z "${export_options_path}" ] && [[ "${xcode_major_version}" == "6" ]] ;
4544
export_options_path=""
4645
fi
4746

48-
if [ -z "${build_tool}" ] ; then
49-
echo "[!] Missing required input: build_tool"
50-
exit 1
51-
elif [[ "${build_tool}" != "xctool" && "${build_tool}" != "xcodebuild" ]] ; then
52-
echo "[!] Invalid build_tool: ${build_tool}"
47+
if [[ "${output_tool}" != "xcpretty" && "${output_tool}" != "xcodebuild" ]] ; then
48+
echo "[!] Invalid output_tool: ${output_tool}"
5349
exit 1
5450
fi
5551

52+
set +e
53+
54+
if [[ "${output_tool}" == "xcpretty" ]] ; then
55+
xcpretty_version=$(xcpretty --version)
56+
exit_code=$?
57+
if [[ $exit_code != 0 || -z $xcpretty_version ]] ; then
58+
echo
59+
echo " (!) xcpretty is not installed"
60+
echo " For xcpretty installation see: 'https://github.com/supermarin/xcpretty',"
61+
echo " or use 'xcodebuild' as 'output_tool'."
62+
echo
63+
exit 1
64+
fi
65+
fi
66+
67+
set -e
68+
5669
#
5770
# Project-or-Workspace flag
5871
if [[ "${project_path}" == *".xcodeproj" ]]; then
@@ -84,7 +97,7 @@ fi
8497
echo
8598
echo "========== Configs =========="
8699
echo " * CONFIG_xcode_project_action: ${CONFIG_xcode_project_action}"
87-
echo " * build_tool: ${build_tool}"
100+
echo " * output_tool: ${output_tool}"
88101
echo " * project_path: ${project_path}"
89102
echo " * scheme: ${scheme}"
90103
echo " * workdir: ${workdir}"
@@ -142,38 +155,40 @@ if [ -f "${ipa_path}" ] ; then
142155
rm "${ipa_path}"
143156
fi
144157

158+
echo
159+
echo
160+
echo "=> Create the Archive ..."
161+
145162
#
146163
# Create the Archive with Xcode Command Line tools
164+
archive_cmd="xcodebuild ${CONFIG_xcode_project_action} \"${project_path}\""
165+
archive_cmd="$archive_cmd -scheme \"${scheme}\" ${xcode_configuration}"
166+
archive_cmd="$archive_cmd ${clean_build_param} archive -archivePath \"${archive_path}\""
167+
147168
if [[ "${is_force_code_sign}" == "yes" ]] ; then
148169
echo " (!) Using Force Code Signing mode!"
149170

150-
echo
151-
echo
152-
153-
set -x
154-
${build_tool} ${CONFIG_xcode_project_action} "${project_path}" \
155-
-scheme "${scheme}" ${xcode_configuration} \
156-
${clean_build_param} archive -archivePath "${archive_path}" \
157-
PROVISIONING_PROFILE="${BITRISE_PROVISIONING_PROFILE_ID}" \
158-
CODE_SIGN_IDENTITY="${BITRISE_CODE_SIGN_IDENTITY}"
159-
else
160-
echo
161-
echo
171+
archive_cmd="$archive_cmd PROVISIONING_PROFILE=\"${BITRISE_PROVISIONING_PROFILE_ID}\""
172+
archive_cmd="$archive_cmd CODE_SIGN_IDENTITY=\"${BITRISE_CODE_SIGN_IDENTITY}\""
173+
fi
162174

163-
set -x
164-
${build_tool} ${CONFIG_xcode_project_action} "${project_path}" \
165-
-scheme "${scheme}" ${xcode_configuration} \
166-
${clean_build_param} archive -archivePath "${archive_path}"
175+
if [[ "${output_tool}" == "xcpretty" ]] ; then
176+
archive_cmd="set -o pipefail && $archive_cmd | xcpretty"
167177
fi
168178

169-
set +x
170-
set +v
179+
echo
180+
echo "archive command:"
181+
echo "$archive_cmd"
182+
echo
183+
184+
eval $archive_cmd
171185

172186
echo
173187
echo
174188
echo "=> Exporting IPA from generated Archive ..."
175189
echo
176-
echo
190+
191+
export_command="xcodebuild -exportArchive"
177192

178193
if [[ "${xcode_major_version}" == "6" ]] ; then
179194
#
@@ -210,20 +225,27 @@ if [[ "${xcode_major_version}" == "6" ]] ; then
210225

211226
echo " (i) Found Profile Name for signing: ${profile_name}"
212227

213-
set -v
214-
215228
#
216229
# Use the Provisioning Profile name to export the IPA
217-
xcodebuild -exportArchive \
218-
-exportFormat ipa \
219-
-archivePath "${archive_path}" \
220-
-exportPath "${ipa_path}" \
221-
-exportProvisioningProfile "${profile_name}"
230+
export_command="$export_command -exportFormat ipa"
231+
export_command="$export_command -archivePath \"${archive_path}\""
232+
export_command="$export_command -exportPath \"${ipa_path}\""
233+
export_command="$export_command -exportProvisioningProfile \"${profile_name}\""
234+
235+
if [[ "${output_tool}" == "xcpretty" ]] ; then
236+
export_command="set -o pipefail && $export_command | xcpretty"
237+
fi
238+
239+
echo
240+
echo "export command:"
241+
echo "$export_command"
242+
echo
243+
244+
eval $export_command
222245
else
223246
echo " (i) Using Xcode 7 'exportOptionsPlist' option"
224247

225248
if [ -z "${export_options_path}" ] ; then
226-
set -x
227249
export_options_path="${output_dir}/export_options.plist"
228250
curr_pwd="$(pwd)"
229251
cd "${THIS_SCRIPT_DIR}"
@@ -232,15 +254,8 @@ else
232254
-o "${export_options_path}" \
233255
-a "${archive_path}"
234256
cd "${curr_pwd}"
235-
set +x
236257
fi
237258

238-
239-
#
240-
# Export the IPA
241-
echo "Content of exportOptionsPlist file:"
242-
cat "${export_options_path}"
243-
244259
#
245260
# Because of an RVM issue which conflicts with `xcodebuild`'s new
246261
# `-exportOptionsPlist` option
@@ -255,16 +270,22 @@ else
255270
rvm use system
256271
fi
257272

258-
set -x
259-
260273
tmp_dir=$(mktemp -d -t bitrise-xcarchive)
261274

262-
xcodebuild -exportArchive \
263-
-archivePath "${archive_path}" \
264-
-exportPath "${tmp_dir}" \
265-
-exportOptionsPlist "${export_options_path}"
275+
export_command="$export_command -archivePath \"${archive_path}\""
276+
export_command="$export_command -exportPath \"${tmp_dir}\""
277+
export_command="$export_command -exportOptionsPlist \"${export_options_path}\""
278+
279+
if [[ "${output_tool}" == "xcpretty" ]] ; then
280+
export_command="set -o pipefail && $export_command | xcpretty"
281+
fi
266282

267-
set +x
283+
echo
284+
echo "export command:"
285+
echo "$export_command"
286+
echo
287+
288+
eval $export_command
268289

269290
# Searching for ipa
270291
exported_ipa_path=""
@@ -300,8 +321,6 @@ else
300321
ipa_path="${exported_ipa_path}"
301322
fi
302323

303-
set +v
304-
305324

306325
#
307326
# Export *.ipa path

step.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ is_skippable: false
1919
deps:
2020
check_only:
2121
- name: xcode
22-
brew:
23-
- name: xctool
2422
run_if: ""
2523
inputs:
2624
- workdir: $BITRISE_SOURCE_DIR
@@ -125,12 +123,15 @@ inputs:
125123
is_required: true
126124
is_expand: true
127125
is_dont_change_value: false
128-
- build_tool: "xctool"
126+
- output_tool: xcpretty
129127
opts:
130-
title: "Build tool"
128+
title: Output tool
129+
description: |-
130+
If output_tool is set to xcpretty, the xcodebuild output will be prettified by xcpretty.
131+
If output_tool is set to xcodebuild, the raw xcodebuild output will be printed.
131132
value_options:
132-
- "xctool"
133-
- "xcodebuild"
133+
- xcpretty
134+
- xcodebuild
134135
is_required: true
135136
is_expand: false
136137
is_dont_change_value: false

0 commit comments

Comments
 (0)