build.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. #!/usr/bin/env bash
  2. # Copyright 2018 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. # USAGE: build.sh product [platform] [method]
  16. #
  17. # Builds the given product for the given platform using the given build method
  18. function pod_gen() {
  19. # Call pod gen with a podspec and additional optional arguments.
  20. bundle exec pod gen --local-sources=./ --sources=https://github.com/firebase/SpecsDev.git,https://github.com/firebase/SpecsStaging.git,https://cdn.cocoapods.org/ "$@"
  21. }
  22. set -euo pipefail
  23. if [[ $# -lt 1 ]]; then
  24. cat 1>&2 <<EOF
  25. USAGE: $0 product [platform] [method]
  26. product can be one of:
  27. Firebase
  28. Firestore
  29. CombineSwift
  30. InAppMessaging
  31. Messaging
  32. MessagingSample
  33. SwiftUISample
  34. MLModelDownloaderSample
  35. RemoteConfig
  36. RemoteConfigSample
  37. Sessions
  38. Storage
  39. SymbolCollision
  40. GoogleDataTransport
  41. Performance
  42. platform can be one of:
  43. iOS (default)
  44. iOS-device
  45. macOS
  46. tvOS
  47. watchOS
  48. catalyst
  49. method can be one of:
  50. xcodebuild (default)
  51. cmake
  52. unit
  53. integration
  54. spm
  55. Optionally, reads the environment variable SANITIZERS. If set, it is expected to
  56. be a string containing a space-separated list with some of the following
  57. elements:
  58. asan
  59. tsan
  60. ubsan
  61. EOF
  62. exit 1
  63. fi
  64. product="$1"
  65. platform="iOS"
  66. if [[ $# -gt 1 ]]; then
  67. platform="$2"
  68. fi
  69. method="xcodebuild"
  70. if [[ $# -gt 2 ]]; then
  71. method="$3"
  72. fi
  73. echo "Building $product for $platform using $method"
  74. if [[ -n "${SANITIZERS:-}" ]]; then
  75. echo "Using sanitizers: $SANITIZERS"
  76. fi
  77. scripts_dir=$(dirname "${BASH_SOURCE[0]}")
  78. firestore_emulator="${scripts_dir}/run_firestore_emulator.sh"
  79. database_emulator="${scripts_dir}/run_database_emulator.sh"
  80. system=$(uname -s)
  81. case "$system" in
  82. Darwin)
  83. xcode_version=$(xcodebuild -version | head -n 1)
  84. xcode_version="${xcode_version/Xcode /}"
  85. xcode_major="${xcode_version/.*/}"
  86. ;;
  87. *)
  88. xcode_major="0"
  89. ;;
  90. esac
  91. # Source function to check if CI secrets are available.
  92. source scripts/check_secrets.sh
  93. # Runs xcodebuild with the given flags, piping output to xcpretty
  94. # If xcodebuild fails with known error codes, retries once.
  95. function RunXcodebuild() {
  96. echo xcodebuild "$@"
  97. xcpretty_cmd=(xcpretty)
  98. result=0
  99. xcodebuild "$@" | tee xcodebuild.log | "${xcpretty_cmd[@]}" || result=$?
  100. if [[ $result == 65 ]]; then
  101. ExportLogs "$@"
  102. echo "xcodebuild exited with 65, retrying" 1>&2
  103. sleep 5
  104. result=0
  105. xcodebuild "$@" | tee xcodebuild.log | "${xcpretty_cmd[@]}" || result=$?
  106. fi
  107. if [[ $result != 0 ]]; then
  108. echo "xcodebuild exited with $result" 1>&2
  109. ExportLogs "$@"
  110. return $result
  111. fi
  112. }
  113. # Exports any logs output captured in the xcresult
  114. function ExportLogs() {
  115. python "${scripts_dir}/xcresult_logs.py" "$@"
  116. }
  117. if [[ "$xcode_major" -lt 11 ]]; then
  118. ios_flags=(
  119. -sdk 'iphonesimulator'
  120. -destination 'platform=iOS Simulator,name=iPhone 7'
  121. )
  122. else
  123. ios_flags=(
  124. -sdk 'iphonesimulator'
  125. -destination 'platform=iOS Simulator,name=iPhone 11'
  126. )
  127. fi
  128. ios_device_flags=(
  129. -sdk 'iphoneos'
  130. -destination 'generic/platform=iOS'
  131. )
  132. ipad_flags=(
  133. -sdk 'iphonesimulator'
  134. -destination 'platform=iOS Simulator,name=iPad Pro (9.7-inch)'
  135. )
  136. macos_flags=(
  137. -sdk 'macosx'
  138. -destination 'platform=OS X,arch=x86_64'
  139. )
  140. tvos_flags=(
  141. -sdk "appletvsimulator"
  142. -destination 'platform=tvOS Simulator,name=Apple TV'
  143. )
  144. watchos_flags=(
  145. -destination 'platform=watchOS Simulator,name=Apple Watch Series 7 (45mm)'
  146. )
  147. catalyst_flags=(
  148. ARCHS=x86_64 VALID_ARCHS=x86_64 SUPPORTS_MACCATALYST=YES -sdk macosx
  149. -destination platform="macOS,variant=Mac Catalyst,arch=x86_64" TARGETED_DEVICE_FAMILY=2
  150. CODE_SIGN_IDENTITY=- CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
  151. )
  152. # Compute standard flags for all platforms
  153. case "$platform" in
  154. iOS)
  155. xcb_flags=("${ios_flags[@]}")
  156. gen_platform=ios
  157. ;;
  158. iOS-device)
  159. xcb_flags=("${ios_device_flags[@]}")
  160. gen_platform=ios
  161. ;;
  162. iPad)
  163. xcb_flags=("${ipad_flags[@]}")
  164. ;;
  165. macOS)
  166. xcb_flags=("${macos_flags[@]}")
  167. gen_platform=macos
  168. ;;
  169. tvOS)
  170. xcb_flags=("${tvos_flags[@]}")
  171. gen_platform=tvos
  172. ;;
  173. watchOS)
  174. xcb_flags=("${watchos_flags[@]}")
  175. ;;
  176. catalyst)
  177. xcb_flags=("${catalyst_flags[@]}")
  178. ;;
  179. all)
  180. xcb_flags=()
  181. ;;
  182. Linux)
  183. xcb_flags=()
  184. ;;
  185. *)
  186. echo "Unknown platform '$platform'" 1>&2
  187. exit 1
  188. ;;
  189. esac
  190. xcb_flags+=(
  191. ONLY_ACTIVE_ARCH=YES
  192. CODE_SIGNING_REQUIRED=NO
  193. CODE_SIGNING_ALLOWED=YES
  194. COMPILER_INDEX_STORE_ENABLE=NO
  195. )
  196. source scripts/buildcache.sh
  197. xcb_flags=("${xcb_flags[@]}" "${buildcache_xcb_flags[@]}")
  198. # TODO(varconst): Add --warn-unused-vars and --warn-uninitialized.
  199. # Right now, it makes the log overflow on Travis because many of our
  200. # dependencies don't build cleanly this way.
  201. cmake_options=(
  202. -Wdeprecated
  203. -DCMAKE_BUILD_TYPE=Debug
  204. )
  205. if [[ -n "${SANITIZERS:-}" ]]; then
  206. for sanitizer in $SANITIZERS; do
  207. case "$sanitizer" in
  208. asan)
  209. xcb_flags+=(
  210. -enableAddressSanitizer YES
  211. )
  212. cmake_options+=(
  213. -DWITH_ASAN=ON
  214. )
  215. ;;
  216. tsan)
  217. xcb_flags+=(
  218. -enableThreadSanitizer YES
  219. )
  220. cmake_options+=(
  221. -DWITH_TSAN=ON
  222. )
  223. ;;
  224. ubsan)
  225. xcb_flags+=(
  226. -enableUndefinedBehaviorSanitizer YES
  227. )
  228. cmake_options+=(
  229. -DWITH_UBSAN=ON
  230. )
  231. ;;
  232. *)
  233. echo "Unknown sanitizer '$sanitizer'" 1>&2
  234. exit 1
  235. ;;
  236. esac
  237. done
  238. fi
  239. case "$product-$platform-$method" in
  240. FirebasePod-iOS-*)
  241. RunXcodebuild \
  242. -workspace 'CoreOnly/Tests/FirebasePodTest/FirebasePodTest.xcworkspace' \
  243. -scheme "FirebasePodTest" \
  244. "${xcb_flags[@]}" \
  245. build
  246. ;;
  247. Auth-*-xcodebuild)
  248. if check_secrets; then
  249. RunXcodebuild \
  250. -workspace 'FirebaseAuth/Tests/Sample/AuthSample.xcworkspace' \
  251. -scheme "Auth_ApiTests" \
  252. "${xcb_flags[@]}" \
  253. build \
  254. test
  255. RunXcodebuild \
  256. -workspace 'FirebaseAuth/Tests/Sample/AuthSample.xcworkspace' \
  257. -scheme "SwiftApiTests" \
  258. "${xcb_flags[@]}" \
  259. build \
  260. test
  261. fi
  262. ;;
  263. CombineSwift-*-xcodebuild)
  264. pod_gen FirebaseCombineSwift.podspec --platforms=ios
  265. RunXcodebuild \
  266. -workspace 'gen/FirebaseCombineSwift/FirebaseCombineSwift.xcworkspace' \
  267. -scheme "FirebaseCombineSwift-Unit-unit" \
  268. "${xcb_flags[@]}" \
  269. build \
  270. test
  271. ;;
  272. InAppMessaging-*-xcodebuild)
  273. RunXcodebuild \
  274. -workspace 'FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp/InAppMessagingDisplay-Sample.xcworkspace' \
  275. -scheme 'FiamDisplaySwiftExample' \
  276. "${xcb_flags[@]}" \
  277. build \
  278. test
  279. ;;
  280. Firestore-*-xcodebuild)
  281. "${firestore_emulator}" start
  282. trap '"${firestore_emulator}" stop' ERR EXIT
  283. RunXcodebuild \
  284. -workspace 'Firestore/Example/Firestore.xcworkspace' \
  285. -scheme "Firestore_IntegrationTests_$platform" \
  286. -enableCodeCoverage YES \
  287. "${xcb_flags[@]}" \
  288. test
  289. ;;
  290. Firestore-macOS-cmake | Firestore-Linux-cmake)
  291. "${firestore_emulator}" start
  292. trap '"${firestore_emulator}" stop' ERR EXIT
  293. (
  294. test -d build || mkdir build
  295. cd build
  296. echo "Preparing cmake build ..."
  297. cmake -G Ninja "${cmake_options[@]}" ..
  298. echo "Building cmake build ..."
  299. ninja -k 10 all
  300. ctest --verbose
  301. )
  302. ;;
  303. SymbolCollision-*-*)
  304. RunXcodebuild \
  305. -workspace 'SymbolCollisionTest/SymbolCollisionTest.xcworkspace' \
  306. -scheme "SymbolCollisionTest" \
  307. "${xcb_flags[@]}" \
  308. build
  309. ;;
  310. Messaging-*-xcodebuild)
  311. pod_gen FirebaseMessaging.podspec --platforms=ios
  312. # Add GoogleService-Info.plist to generated Test Wrapper App.
  313. ruby ./scripts/update_xcode_target.rb gen/FirebaseMessaging/Pods/Pods.xcodeproj \
  314. AppHost-FirebaseMessaging-Unit-Tests \
  315. ../../../FirebaseMessaging/Tests/IntegrationTests/Resources/GoogleService-Info.plist
  316. RunXcodebuild \
  317. -workspace 'gen/FirebaseMessaging/FirebaseMessaging.xcworkspace' \
  318. -scheme "FirebaseMessaging-Unit-unit" \
  319. "${ios_flags[@]}" \
  320. "${xcb_flags[@]}" \
  321. build \
  322. test
  323. if check_secrets; then
  324. # Integration tests are only run on iOS to minimize flake failures.
  325. RunXcodebuild \
  326. -workspace 'gen/FirebaseMessaging/FirebaseMessaging.xcworkspace' \
  327. -scheme "FirebaseMessaging-Unit-integration" \
  328. "${ios_flags[@]}" \
  329. "${xcb_flags[@]}" \
  330. build \
  331. test
  332. fi
  333. pod_gen FirebaseMessaging.podspec --platforms=macos --clean
  334. RunXcodebuild \
  335. -workspace 'gen/FirebaseMessaging/FirebaseMessaging.xcworkspace' \
  336. -scheme "FirebaseMessaging-Unit-unit" \
  337. "${macos_flags[@]}" \
  338. "${xcb_flags[@]}" \
  339. build \
  340. test
  341. pod_gen FirebaseMessaging.podspec --platforms=tvos --clean
  342. RunXcodebuild \
  343. -workspace 'gen/FirebaseMessaging/FirebaseMessaging.xcworkspace' \
  344. -scheme "FirebaseMessaging-Unit-unit" \
  345. "${tvos_flags[@]}" \
  346. "${xcb_flags[@]}" \
  347. build \
  348. test
  349. ;;
  350. MessagingSample-*-*)
  351. if check_secrets; then
  352. RunXcodebuild \
  353. -workspace 'FirebaseMessaging/Apps/Sample/Sample.xcworkspace' \
  354. -scheme "Sample" \
  355. "${xcb_flags[@]}" \
  356. build
  357. fi
  358. ;;
  359. SwiftUISample-*-*)
  360. if check_secrets; then
  361. RunXcodebuild \
  362. -workspace 'FirebaseMessaging/Apps/SwiftUISample/SwiftUISample.xcworkspace' \
  363. -scheme "SwiftUISample" \
  364. "${xcb_flags[@]}" \
  365. build
  366. fi
  367. ;;
  368. MessagingSampleStandaloneWatchApp-*-*)
  369. if check_secrets; then
  370. RunXcodebuild \
  371. -workspace 'FirebaseMessaging/Apps/SampleStandaloneWatchApp/SampleStandaloneWatchApp.xcworkspace' \
  372. -scheme "SampleStandaloneWatchApp Watch App" \
  373. "${xcb_flags[@]}" \
  374. build
  375. fi
  376. ;;
  377. MLModelDownloaderSample-*-*)
  378. if check_secrets; then
  379. RunXcodebuild \
  380. -workspace 'FirebaseMLModelDownloader/Apps/Sample/MLDownloaderTestApp.xcworkspace' \
  381. -scheme "MLDownloaderTestApp" \
  382. "${xcb_flags[@]}" \
  383. build
  384. fi
  385. ;;
  386. WatchOSSample-*-*)
  387. RunXcodebuild \
  388. -workspace 'Example/watchOSSample/SampleWatchApp.xcworkspace' \
  389. -scheme "SampleWatchAppWatchKitApp" \
  390. "${xcb_flags[@]}" \
  391. build
  392. ;;
  393. Database-*-unit)
  394. pod_gen FirebaseDatabase.podspec --platforms="${gen_platform}"
  395. RunXcodebuild \
  396. -workspace 'gen/FirebaseDatabase/FirebaseDatabase.xcworkspace' \
  397. -scheme "FirebaseDatabase-Unit-unit" \
  398. "${xcb_flags[@]}" \
  399. build \
  400. test
  401. ;;
  402. Database-*-integration)
  403. "${database_emulator}" start
  404. trap '"${database_emulator}" stop' ERR EXIT
  405. pod_gen FirebaseDatabase.podspec --platforms="${gen_platform}"
  406. RunXcodebuild \
  407. -workspace 'gen/FirebaseDatabase/FirebaseDatabase.xcworkspace' \
  408. -scheme "FirebaseDatabase-Unit-integration" \
  409. "${xcb_flags[@]}" \
  410. build \
  411. test
  412. ;;
  413. RemoteConfig-*-fakeconsole)
  414. pod_gen FirebaseRemoteConfigSwift.podspec --platforms="${gen_platform}"
  415. RunXcodebuild \
  416. -workspace 'gen/FirebaseRemoteConfigSwift/FirebaseRemoteConfigSwift.xcworkspace' \
  417. -scheme "FirebaseRemoteConfigSwift-Unit-fake-console-tests" \
  418. "${xcb_flags[@]}" \
  419. build \
  420. test
  421. ;;
  422. RemoteConfig-*-integration)
  423. pod_gen FirebaseRemoteConfigSwift.podspec --platforms="${gen_platform}"
  424. # Add GoogleService-Info.plist to generated Test Wrapper App.
  425. ruby ./scripts/update_xcode_target.rb gen/FirebaseRemoteConfigSwift/Pods/Pods.xcodeproj \
  426. AppHost-FirebaseRemoteConfigSwift-Unit-Tests \
  427. ../../../FirebaseRemoteConfigSwift/Tests/SwiftAPI/GoogleService-Info.plist
  428. # Add AccessToken to generated Test Wrapper App.
  429. ruby ./scripts/update_xcode_target.rb gen/FirebaseRemoteConfigSwift/Pods/Pods.xcodeproj \
  430. AppHost-FirebaseRemoteConfigSwift-Unit-Tests \
  431. ../../../FirebaseRemoteConfigSwift/Tests/AccessToken.json
  432. RunXcodebuild \
  433. -workspace 'gen/FirebaseRemoteConfigSwift/FirebaseRemoteConfigSwift.xcworkspace' \
  434. -scheme "FirebaseRemoteConfigSwift-Unit-swift-api-tests" \
  435. "${xcb_flags[@]}" \
  436. build \
  437. test
  438. ;;
  439. RemoteConfigSample-*-*)
  440. RunXcodebuild \
  441. -workspace 'FirebaseRemoteConfig/Tests/Sample/RemoteConfigSampleApp.xcworkspace' \
  442. -scheme "RemoteConfigSampleApp" \
  443. "${xcb_flags[@]}" \
  444. build
  445. ;;
  446. Sessions-*-integration)
  447. # Perform "pod install" to install the relevant dependencies
  448. # ./FirebaseSessions/generate_testapp.sh
  449. pod_gen FirebaseSessions.podspec --platforms=ios --clean
  450. cd FirebaseSessions/Tests/TestApp; pod install; cd -
  451. # Run E2E Integration Tests for Prod.
  452. RunXcodebuild \
  453. -workspace 'FirebaseSessions/Tests/TestApp/AppQualityDevApp.xcworkspace' \
  454. -scheme "AppQualityDevApp_iOS" \
  455. "${ios_flags[@]}" \
  456. "${xcb_flags[@]}" \
  457. build \
  458. test
  459. # Run E2E Integration Tests for Staging.
  460. RunXcodebuild \
  461. -workspace 'FirebaseSessions/Tests/TestApp/AppQualityDevApp.xcworkspace' \
  462. -scheme "AppQualityDevApp_iOS" \
  463. FirebaseSessionsRunEnvironment=STAGING \
  464. "${ios_flags[@]}" \
  465. "${xcb_flags[@]}" \
  466. build \
  467. test
  468. # Run E2E Integration Tests for Autopush.
  469. RunXcodebuild \
  470. -workspace 'FirebaseSessions/Tests/TestApp/AppQualityDevApp.xcworkspace' \
  471. -scheme "AppQualityDevApp_iOS" \
  472. FirebaseSessionsRunEnvironment=AUTOPUSH \
  473. "${ios_flags[@]}" \
  474. "${xcb_flags[@]}" \
  475. build \
  476. test
  477. ;;
  478. Storage-*-xcodebuild)
  479. pod_gen FirebaseStorage.podspec --platforms=ios
  480. # Add GoogleService-Info.plist to generated Test Wrapper App.
  481. ruby ./scripts/update_xcode_target.rb gen/FirebaseStorage/Pods/Pods.xcodeproj \
  482. AppHost-FirebaseStorage-Unit-Tests \
  483. ../../../FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist
  484. if check_secrets; then
  485. # Integration tests are only run on iOS to minimize flake failures.
  486. RunXcodebuild \
  487. -workspace 'gen/FirebaseStorage/FirebaseStorage.xcworkspace' \
  488. -scheme "FirebaseStorage-Unit-integration" \
  489. "${ios_flags[@]}" \
  490. "${xcb_flags[@]}" \
  491. build \
  492. test
  493. fi
  494. if check_secrets; then
  495. # Integration tests are only run on iOS to minimize flake failures.
  496. RunXcodebuild \
  497. -workspace 'gen/FirebaseStorage/FirebaseStorage.xcworkspace' \
  498. -scheme "FirebaseStorage-Unit-ObjCIntegration" \
  499. "${ios_flags[@]}" \
  500. "${xcb_flags[@]}" \
  501. build \
  502. test
  503. fi
  504. ;;
  505. StorageCombine-*-xcodebuild)
  506. pod_gen FirebaseCombineSwift.podspec --platforms=ios
  507. # Add GoogleService-Info.plist to generated Test Wrapper App.
  508. ruby ./scripts/update_xcode_target.rb gen/FirebaseCombineSwift/Pods/Pods.xcodeproj \
  509. AppHost-FirebaseCombineSwift-Unit-Tests \
  510. ../../../FirebaseStorage/Tests/Integration/Resources/GoogleService-Info.plist
  511. if check_secrets; then
  512. # Integration tests are only run on iOS to minimize flake failures.
  513. RunXcodebuild \
  514. -workspace 'gen/FirebaseCombineSwift/FirebaseCombineSwift.xcworkspace' \
  515. -scheme "FirebaseCombineSwift-Unit-integration" \
  516. "${ios_flags[@]}" \
  517. "${xcb_flags[@]}" \
  518. build \
  519. test
  520. fi
  521. ;;
  522. GoogleDataTransport-watchOS-xcodebuild)
  523. RunXcodebuild \
  524. -workspace 'GoogleDataTransport/GDTWatchOSTestApp/GDTWatchOSTestApp.xcworkspace' \
  525. -scheme "GDTWatchOSTestAppWatchKitApp" \
  526. "${xcb_flags[@]}" \
  527. build
  528. RunXcodebuild \
  529. -workspace 'GoogleDataTransport/GDTCCTWatchOSTestApp/GDTCCTWatchOSTestApp.xcworkspace' \
  530. -scheme "GDTCCTWatchOSIndependentTestAppWatchKitApp" \
  531. "${xcb_flags[@]}" \
  532. build
  533. RunXcodebuild \
  534. -workspace 'GoogleDataTransport/GDTCCTWatchOSTestApp/GDTCCTWatchOSTestApp.xcworkspace' \
  535. -scheme "GDTCCTWatchOSCompanionTestApp" \
  536. "${xcb_flags[@]}" \
  537. build
  538. ;;
  539. Performance-*-unit)
  540. # Run unit tests on prod environment with unswizzle capabilities.
  541. export FPR_UNSWIZZLE_AVAILABLE="1"
  542. export FPR_AUTOPUSH_ENV="0"
  543. pod_gen FirebasePerformance.podspec --platforms="${gen_platform}"
  544. RunXcodebuild \
  545. -workspace 'gen/FirebasePerformance/FirebasePerformance.xcworkspace' \
  546. -scheme "FirebasePerformance-Unit-unit" \
  547. "${xcb_flags[@]}" \
  548. build \
  549. test
  550. ;;
  551. Performance-*-proddev)
  552. # Build the prod dev test app.
  553. export FPR_UNSWIZZLE_AVAILABLE="0"
  554. export FPR_AUTOPUSH_ENV="0"
  555. pod_gen FirebasePerformance.podspec --platforms="${gen_platform}"
  556. RunXcodebuild \
  557. -workspace 'gen/FirebasePerformance/FirebasePerformance.xcworkspace' \
  558. -scheme "FirebasePerformance-TestApp" \
  559. "${xcb_flags[@]}" \
  560. build
  561. ;;
  562. Performance-*-integration)
  563. # Generate the workspace for the SDK to generate Protobuf files.
  564. export FPR_UNSWIZZLE_AVAILABLE="0"
  565. pod_gen FirebasePerformance.podspec --platforms=ios --clean
  566. # Perform "pod install" to install the relevant dependencies
  567. cd FirebasePerformance/Tests/FIRPerfE2E; pod install; cd -
  568. # Run E2E Integration Tests for Autopush.
  569. RunXcodebuild \
  570. -workspace 'FirebasePerformance/Tests/FIRPerfE2E/FIRPerfE2E.xcworkspace' \
  571. -scheme "FIRPerfE2EAutopush" \
  572. FPR_AUTOPUSH_ENV=1 \
  573. "${ios_flags[@]}" \
  574. "${xcb_flags[@]}" \
  575. build \
  576. test
  577. # Run E2E Integration Tests for Prod.
  578. RunXcodebuild \
  579. -workspace 'FirebasePerformance/Tests/FIRPerfE2E/FIRPerfE2E.xcworkspace' \
  580. -scheme "FIRPerfE2EProd" \
  581. "${ios_flags[@]}" \
  582. "${xcb_flags[@]}" \
  583. build \
  584. test
  585. ;;
  586. # Note that the combine tests require setting the minimum iOS and tvOS version to 13.0
  587. *-*-spm)
  588. RunXcodebuild \
  589. -scheme $product \
  590. "${xcb_flags[@]}" \
  591. IPHONEOS_DEPLOYMENT_TARGET=13.0 \
  592. TVOS_DEPLOYMENT_TARGET=13.0 \
  593. test
  594. ;;
  595. *-*-spmbuildonly)
  596. RunXcodebuild \
  597. -scheme $product \
  598. "${xcb_flags[@]}" \
  599. build
  600. ;;
  601. SwiftPMClientApp-*-xcodebuild)
  602. RunXcodebuild \
  603. -project 'SwiftPMTests/ClientApp/ClientApp.xcodeproj' \
  604. -scheme "ClientApp" \
  605. "${xcb_flags[@]}" \
  606. build
  607. ;;
  608. *)
  609. echo "Don't know how to build this product-platform-method combination" 1>&2
  610. echo " product=$product" 1>&2
  611. echo " platform=$platform" 1>&2
  612. echo " method=$method" 1>&2
  613. exit 1
  614. ;;
  615. esac