1 |
efrain |
1 |
#!/bin/sh
|
|
|
2 |
|
|
|
3 |
# Copyright 2019 Google
|
|
|
4 |
#
|
|
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
6 |
# you may not use this file except in compliance with the License.
|
|
|
7 |
# You may obtain a copy of the License at
|
|
|
8 |
#
|
|
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
10 |
#
|
|
|
11 |
# Unless required by applicable law or agreed to in writing, software
|
|
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
14 |
# See the License for the specific language governing permissions and
|
|
|
15 |
# limitations under the License.
|
|
|
16 |
#
|
|
|
17 |
# run
|
|
|
18 |
#
|
|
|
19 |
# This script is meant to be run as a Run Script in the "Build Phases" section
|
|
|
20 |
# of your Xcode project. It sends debug symbols to symbolicate stacktraces,
|
|
|
21 |
# sends build events to track versions, and onboards apps for Crashlytics.
|
|
|
22 |
#
|
|
|
23 |
# This script calls upload-symbols twice:
|
|
|
24 |
#
|
|
|
25 |
# 1) First it calls upload-symbols synchronously in "validation" mode. If the
|
|
|
26 |
# script finds issues with the build environment, it will report errors to Xcode.
|
|
|
27 |
# In validation mode it exits before doing any time consuming work.
|
|
|
28 |
#
|
|
|
29 |
# 2) Then it calls upload-symbols in the background to actually send the build
|
|
|
30 |
# event and upload symbols. It does this in the background so that it doesn't
|
|
|
31 |
# slow down your builds. If an error happens here, you won't see it in Xcode.
|
|
|
32 |
#
|
|
|
33 |
# You can find the output for the background execution in Console.app, by
|
|
|
34 |
# searching for "upload-symbols".
|
|
|
35 |
#
|
|
|
36 |
# If you want verbose output, you can pass the --debug flag to this script
|
|
|
37 |
#
|
|
|
38 |
|
|
|
39 |
# Figure out where we're being called from
|
|
|
40 |
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
|
41 |
|
|
|
42 |
# Build up the arguments list, passing through any flags added, and quoting
|
|
|
43 |
# every argument in case there are spaces in any of the the paths.
|
|
|
44 |
ARGUMENTS=''
|
|
|
45 |
for i in "$@"; do
|
|
|
46 |
ARGUMENTS="$ARGUMENTS \"$i\""
|
|
|
47 |
done
|
|
|
48 |
|
|
|
49 |
VALIDATE_ARGUMENTS="$ARGUMENTS --build-phase --validate"
|
|
|
50 |
UPLOAD_ARGUMENTS="$ARGUMENTS --build-phase"
|
|
|
51 |
|
|
|
52 |
# Quote the path to handle folders with special characters
|
|
|
53 |
COMMAND_PATH="\"$DIR/upload-symbols\" "
|
|
|
54 |
|
|
|
55 |
# Ensure params are as expected, run in sync mode to validate,
|
|
|
56 |
# and cause a build error if validation fails
|
|
|
57 |
eval $COMMAND_PATH$VALIDATE_ARGUMENTS
|
|
|
58 |
return_code=$?
|
|
|
59 |
|
|
|
60 |
if [[ $return_code != 0 ]]; then
|
|
|
61 |
exit $return_code
|
|
|
62 |
fi
|
|
|
63 |
|
|
|
64 |
# Verification passed, convert and upload dSYMs in the background to prevent
|
|
|
65 |
# build delays
|
|
|
66 |
#
|
|
|
67 |
# Note: Validation is performed again at this step before upload
|
|
|
68 |
#
|
|
|
69 |
# Note: Output can still be found in Console.app, by searching for
|
|
|
70 |
# "upload-symbols"
|
|
|
71 |
#
|
|
|
72 |
eval $COMMAND_PATH$UPLOAD_ARGUMENTS > /dev/null 2>&1 &
|