You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.6 KiB

  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. # If the first argument is specified without a dash, treat it as the Fabric API
  40. # Key and add it as an argument.
  41. if [ -z "$1" ] || [[ $1 == -* ]]; then
  42. API_KEY_ARG=""
  43. else
  44. API_KEY_ARG="-a $1"; shift
  45. fi
  46. # Build up the arguments list, passing through any flags added after the
  47. # API Key
  48. ARGUMENTS="$API_KEY_ARG $@"
  49. VALIDATE_ARGUMENTS="$ARGUMENTS --build-phase --validate"
  50. UPLOAD_ARGUMENTS="$ARGUMENTS --build-phase"
  51. # Quote the path to handle folders with special characters
  52. COMMAND_PATH="\"$DIR/upload-symbols\" "
  53. # Ensure params are as expected, run in sync mode to validate,
  54. # and cause a build error if validation fails
  55. eval $COMMAND_PATH$VALIDATE_ARGUMENTS
  56. return_code=$?
  57. if [[ $return_code != 0 ]]; then
  58. exit $return_code
  59. fi
  60. # Verification passed, convert and upload cSYMs in the background to prevent
  61. # build delays
  62. #
  63. # Note: Validation is performed again at this step before upload
  64. #
  65. # Note: Output can still be found in Console.app, by searching for
  66. # "upload-symbols"
  67. #
  68. eval $COMMAND_PATH$UPLOAD_ARGUMENTS > /dev/null 2>&1 &