run 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. # run
  3. #
  4. # Copyright (c) 2015 Crashlytics. All rights reserved.
  5. #
  6. #
  7. # This script is meant to be run as a Run Script in the "Build Phases" section
  8. # of your Xcode project. It sends debug symbols to symbolicate stacktraces,
  9. # sends build events to track versions, and onboard apps for Crashlytics.
  10. #
  11. # This script calls upload-symbols twice:
  12. #
  13. # 1) First it calls upload-symbols synchronously in "validation" mode. If the
  14. # script finds issues with the build environment, it will report errors to Xcode.
  15. # In validation mode it exits before doing any time consuming work.
  16. #
  17. # 2) Then it calls upload-symbols in the background to actually send the build
  18. # event and upload symbols. It does this in the background so that it doesn't
  19. # slow down your builds. If an error happens here, you won't see it in Xcode.
  20. #
  21. # You can find the output for the background execution in Console.app, by
  22. # searching for "upload-symbols".
  23. #
  24. # If you want verbose output, you can pass the --debug flag to this script
  25. #
  26. # Figure out where we're being called from
  27. DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
  28. # If the first argument is specified without a dash, treat it as the Fabric API
  29. # Key and add it as an argument
  30. if [ -z "$1" ] || [[ $1 == -* ]]; then
  31. API_KEY_ARG=""
  32. else
  33. API_KEY_ARG="-a $1"; shift
  34. fi
  35. # If a second argument is specified without a dash, treat it as the Build Secret
  36. # and add it as an argument
  37. if [ -z "$1" ] || [[ $1 == -* ]]; then
  38. BUILD_SECRET_ARG=""
  39. else
  40. BUILD_SECRET_ARG="-bs $1"; shift
  41. fi
  42. # Build up the arguments list, passing through any flags added after the
  43. # API Key and Build Secret
  44. ARGUMENTS="$API_KEY_ARG $BUILD_SECRET_ARG $@"
  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 cSYMs 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 &