test_archiving.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env bash
  2. # Copyright 2020 Google LLC
  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. # USAGE: test_archiving.sh pod platform outputPath
  16. #
  17. # Generates the project for the given CocoaPod and attempts to archive it to the provided
  18. # path.
  19. set -xeuo pipefail
  20. pod="$1"
  21. platform="$2"
  22. output_path="$3"
  23. # watchOS is unsupported - `pod gen` can't generate the test schemes.
  24. case "$platform" in
  25. ios)
  26. scheme_name="App-iOS"
  27. ;;
  28. macos)
  29. scheme_name="App-macOS"
  30. ;;
  31. tvos)
  32. scheme_name="App-tvOS"
  33. ;;
  34. # Fail for anything else, invalid input.
  35. *)
  36. exit 1;
  37. ;;
  38. esac
  39. bundle exec pod gen --local-sources=./ --sources=https://github.com/firebase/SpecsDev.git,https://github.com/firebase/SpecsStaging.git,https://cdn.cocoapods.org/ \
  40. "$pod".podspec --platforms="$platform"
  41. args=(
  42. # Run the `archive` command.
  43. "archive"
  44. # Write the archive to a given path.
  45. "-archivePath" "$output_path"
  46. # The generated workspace.
  47. "-workspace" "gen/$pod/$pod.xcworkspace"
  48. # Specify the generated App scheme.
  49. "-scheme" "$scheme_name"
  50. # Disable signing.
  51. "CODE_SIGN_IDENTITY=-" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGNING_ALLOWED=NO"
  52. )
  53. xcodebuild -version
  54. xcodebuild "${args[@]}" | xcpretty
  55. # Print the size if the Xcode build was successful.
  56. if [ $? -eq 0 ]; then
  57. echo "Size of archive:"
  58. # Use `du` to print the file size of all .apps found. The `k` argument prints in KB.
  59. du -sk $(find "$output_path" -name "*.app")
  60. fi