run 2.5 KB

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