zip_quickstart_test.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. # Copyright 2022 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. # Build the quickstart. If we're running on the main repo (not a fork), we
  16. # also run the tests along with the decoded GoogleService-Info.plist files.
  17. set -eo pipefail
  18. set -x
  19. EXIT_STATUS=0
  20. cd "${SAMPLE}"
  21. if [[ ! -z "$LEGACY" ]]; then
  22. cd "Legacy${SAMPLE}Quickstart"
  23. fi
  24. xcode_version=$(xcodebuild -version | grep Xcode)
  25. xcode_version="${xcode_version/Xcode /}"
  26. xcode_major="${xcode_version/.*/}"
  27. if [[ "$xcode_major" -lt 15 ]]; then
  28. device_name="iPhone 14"
  29. elif [[ "$xcode_major" -lt 16 ]]; then
  30. device_name="iPhone 15"
  31. else
  32. device_name="iPhone 16"
  33. fi
  34. # Define project and scheme names
  35. PROJECT_NAME="${SAMPLE}Example.xcodeproj"
  36. SCHEME_NAME="${SAMPLE}Example${SWIFT_SUFFIX}"
  37. # Check if the scheme exists before attempting to build.
  38. # The `awk` command prints all lines from "Schemes:" to the end of the output.
  39. if ! xcodebuild -list -project "${PROJECT_NAME}" | awk '/Schemes:/,0' | grep -q "^\s*${SCHEME_NAME}"$; then
  40. echo "Error: Scheme '${SCHEME_NAME}' not found in project '${PROJECT_NAME}'."
  41. echo "Available schemes from '${PROJECT_NAME}':"
  42. xcodebuild -list -project "${PROJECT_NAME}"
  43. exit 65
  44. fi
  45. (
  46. xcodebuild \
  47. -project ${PROJECT_NAME} \
  48. -scheme ${SCHEME_NAME} \
  49. -destination "platform=iOS Simulator,name=$device_name" "SWIFT_VERSION=5.3" "OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -ObjC" "FRAMEWORK_SEARCH_PATHS= \$(PROJECT_DIR)/Firebase/" HEADER_SEARCH_PATHS='$(PROJECT_DIR)/Firebase' \
  50. build \
  51. ) || EXIT_STATUS=$?
  52. exit $EXIT_STATUS