fastlane_hotfix 2.165.1 → 2.187.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (415) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +106 -86
  4. data/cert/lib/cert/commands_generator.rb +2 -1
  5. data/cert/lib/cert/options.rb +6 -5
  6. data/cert/lib/cert/runner.rb +8 -8
  7. data/deliver/lib/assets/summary.html.erb +10 -10
  8. data/deliver/lib/deliver/app_screenshot.rb +17 -11
  9. data/deliver/lib/deliver/app_screenshot_validator.rb +108 -0
  10. data/deliver/lib/deliver/commands_generator.rb +4 -3
  11. data/deliver/lib/deliver/detect_values.rb +5 -3
  12. data/deliver/lib/deliver/download_screenshots.rb +2 -3
  13. data/deliver/lib/deliver/html_generator.rb +2 -2
  14. data/deliver/lib/deliver/languages.rb +1 -1
  15. data/deliver/lib/deliver/loader.rb +123 -21
  16. data/deliver/lib/deliver/module.rb +6 -0
  17. data/deliver/lib/deliver/options.rb +41 -55
  18. data/deliver/lib/deliver/runner.rb +19 -14
  19. data/deliver/lib/deliver/setup.rb +9 -5
  20. data/deliver/lib/deliver/submit_for_review.rb +4 -4
  21. data/deliver/lib/deliver/upload_metadata.rb +32 -21
  22. data/deliver/lib/deliver/upload_price_tier.rb +1 -1
  23. data/deliver/lib/deliver/upload_screenshots.rb +14 -76
  24. data/fastlane/lib/fastlane/actions/actions_helper.rb +3 -3
  25. data/fastlane/lib/fastlane/actions/adb.rb +2 -5
  26. data/fastlane/lib/fastlane/actions/adb_devices.rb +0 -1
  27. data/fastlane/lib/fastlane/actions/add_git_tag.rb +22 -6
  28. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +17 -17
  29. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +21 -7
  30. data/fastlane/lib/fastlane/actions/appaloosa.rb +7 -2
  31. data/fastlane/lib/fastlane/actions/appetize.rb +13 -8
  32. data/fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb +0 -11
  33. data/fastlane/lib/fastlane/actions/appium.rb +40 -65
  34. data/fastlane/lib/fastlane/actions/appledoc.rb +46 -46
  35. data/fastlane/lib/fastlane/actions/apteligent.rb +3 -2
  36. data/fastlane/lib/fastlane/actions/artifactory.rb +41 -9
  37. data/fastlane/lib/fastlane/actions/automatic_code_signing.rb +7 -13
  38. data/fastlane/lib/fastlane/actions/backup_file.rb +1 -1
  39. data/fastlane/lib/fastlane/actions/backup_xcarchive.rb +3 -3
  40. data/fastlane/lib/fastlane/actions/badge.rb +9 -13
  41. data/fastlane/lib/fastlane/actions/build_and_upload_to_appetize.rb +11 -5
  42. data/fastlane/lib/fastlane/actions/build_app.rb +7 -1
  43. data/fastlane/lib/fastlane/actions/bundle_install.rb +8 -10
  44. data/fastlane/lib/fastlane/actions/carthage.rb +22 -14
  45. data/fastlane/lib/fastlane/actions/changelog_from_git_commits.rb +8 -17
  46. data/fastlane/lib/fastlane/actions/chatwork.rb +3 -2
  47. data/fastlane/lib/fastlane/actions/check_app_store_metadata.rb +9 -1
  48. data/fastlane/lib/fastlane/actions/clean_build_artifacts.rb +0 -1
  49. data/fastlane/lib/fastlane/actions/clean_cocoapods_cache.rb +0 -1
  50. data/fastlane/lib/fastlane/actions/clipboard.rb +3 -6
  51. data/fastlane/lib/fastlane/actions/cloc.rb +9 -13
  52. data/fastlane/lib/fastlane/actions/cocoapods.rb +23 -15
  53. data/fastlane/lib/fastlane/actions/commit_github_file.rb +12 -4
  54. data/fastlane/lib/fastlane/actions/commit_version_bump.rb +6 -7
  55. data/fastlane/lib/fastlane/actions/copy_artifacts.rb +3 -4
  56. data/fastlane/lib/fastlane/actions/crashlytics.rb +7 -11
  57. data/fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb +70 -76
  58. data/fastlane/lib/fastlane/actions/create_keychain.rb +13 -11
  59. data/fastlane/lib/fastlane/actions/create_pull_request.rb +15 -9
  60. data/fastlane/lib/fastlane/actions/create_xcframework.rb +123 -0
  61. data/fastlane/lib/fastlane/actions/danger.rb +13 -12
  62. data/fastlane/lib/fastlane/actions/deploygate.rb +1 -2
  63. data/fastlane/lib/fastlane/actions/docs/build_app.md +1 -1
  64. data/fastlane/lib/fastlane/actions/docs/capture_android_screenshots.md +27 -28
  65. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +7 -3
  66. data/fastlane/lib/fastlane/actions/docs/create_app_online.md +171 -67
  67. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +20 -3
  68. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +9 -3
  69. data/fastlane/lib/fastlane/actions/docs/upload_to_app_store.md.erb +39 -16
  70. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +2 -1
  71. data/fastlane/lib/fastlane/actions/docs/upload_to_testflight.md +15 -5
  72. data/fastlane/lib/fastlane/actions/download_app_privacy_details_from_app_store.rb +142 -0
  73. data/fastlane/lib/fastlane/actions/download_dsyms.rb +8 -20
  74. data/fastlane/lib/fastlane/actions/dsym_zip.rb +1 -1
  75. data/fastlane/lib/fastlane/actions/ensure_env_vars.rb +2 -6
  76. data/fastlane/lib/fastlane/actions/ensure_git_branch.rb +0 -1
  77. data/fastlane/lib/fastlane/actions/ensure_git_status_clean.rb +3 -4
  78. data/fastlane/lib/fastlane/actions/ensure_no_debug_code.rb +3 -5
  79. data/fastlane/lib/fastlane/actions/ensure_xcode_version.rb +1 -2
  80. data/fastlane/lib/fastlane/actions/environment_variable.rb +13 -21
  81. data/fastlane/lib/fastlane/actions/erb.rb +2 -5
  82. data/fastlane/lib/fastlane/actions/get_build_number_repository.rb +1 -1
  83. data/fastlane/lib/fastlane/actions/get_certificates.rb +5 -1
  84. data/fastlane/lib/fastlane/actions/get_github_release.rb +11 -1
  85. data/fastlane/lib/fastlane/actions/get_ipa_info_plist_value.rb +0 -1
  86. data/fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb +32 -35
  87. data/fastlane/lib/fastlane/actions/get_provisioning_profile.rb +9 -1
  88. data/fastlane/lib/fastlane/actions/get_push_certificate.rb +1 -1
  89. data/fastlane/lib/fastlane/actions/get_version_number.rb +17 -10
  90. data/fastlane/lib/fastlane/actions/git_add.rb +5 -10
  91. data/fastlane/lib/fastlane/actions/git_branch.rb +4 -10
  92. data/fastlane/lib/fastlane/actions/git_commit.rb +12 -10
  93. data/fastlane/lib/fastlane/actions/git_pull.rb +4 -10
  94. data/fastlane/lib/fastlane/actions/git_remote_branch.rb +57 -0
  95. data/fastlane/lib/fastlane/actions/git_submodule_update.rb +16 -8
  96. data/fastlane/lib/fastlane/actions/git_tag_exists.rb +4 -0
  97. data/fastlane/lib/fastlane/actions/github_api.rb +17 -8
  98. data/fastlane/lib/fastlane/actions/gradle.rb +12 -20
  99. data/fastlane/lib/fastlane/actions/hg_commit_version_bump.rb +1 -1
  100. data/fastlane/lib/fastlane/actions/hg_push.rb +1 -1
  101. data/fastlane/lib/fastlane/actions/hipchat.rb +6 -6
  102. data/fastlane/lib/fastlane/actions/hockey.rb +5 -12
  103. data/fastlane/lib/fastlane/actions/ifttt.rb +3 -6
  104. data/fastlane/lib/fastlane/actions/import_from_git.rb +7 -9
  105. data/fastlane/lib/fastlane/actions/increment_build_number.rb +8 -2
  106. data/fastlane/lib/fastlane/actions/install_on_device.rb +3 -6
  107. data/fastlane/lib/fastlane/actions/install_provisioning_profile.rb +4 -0
  108. data/fastlane/lib/fastlane/actions/installr.rb +22 -25
  109. data/fastlane/lib/fastlane/actions/ipa.rb +2 -2
  110. data/fastlane/lib/fastlane/actions/jazzy.rb +11 -8
  111. data/fastlane/lib/fastlane/actions/jira.rb +61 -14
  112. data/fastlane/lib/fastlane/actions/latest_testflight_build_number.rb +6 -6
  113. data/fastlane/lib/fastlane/actions/lcov.rb +0 -4
  114. data/fastlane/lib/fastlane/actions/mailgun.rb +21 -27
  115. data/fastlane/lib/fastlane/actions/make_changelog_from_jenkins.rb +1 -1
  116. data/fastlane/lib/fastlane/actions/match_nuke.rb +59 -0
  117. data/fastlane/lib/fastlane/actions/modify_services.rb +59 -24
  118. data/fastlane/lib/fastlane/actions/nexus_upload.rb +3 -2
  119. data/fastlane/lib/fastlane/actions/notarize.rb +98 -54
  120. data/fastlane/lib/fastlane/actions/notification.rb +1 -1
  121. data/fastlane/lib/fastlane/actions/number_of_commits.rb +1 -1
  122. data/fastlane/lib/fastlane/actions/oclint.rb +15 -14
  123. data/fastlane/lib/fastlane/actions/onesignal.rb +13 -3
  124. data/fastlane/lib/fastlane/actions/pod_push.rb +9 -2
  125. data/fastlane/lib/fastlane/actions/podio_item.rb +0 -7
  126. data/fastlane/lib/fastlane/actions/prompt.rb +3 -4
  127. data/fastlane/lib/fastlane/actions/push_git_tags.rb +1 -1
  128. data/fastlane/lib/fastlane/actions/push_to_git_remote.rb +14 -3
  129. data/fastlane/lib/fastlane/actions/puts.rb +1 -2
  130. data/fastlane/lib/fastlane/actions/register_device.rb +10 -13
  131. data/fastlane/lib/fastlane/actions/register_devices.rb +11 -14
  132. data/fastlane/lib/fastlane/actions/reset_git_repo.rb +5 -8
  133. data/fastlane/lib/fastlane/actions/reset_simulator_contents.rb +0 -2
  134. data/fastlane/lib/fastlane/actions/resign.rb +2 -9
  135. data/fastlane/lib/fastlane/actions/restore_file.rb +1 -1
  136. data/fastlane/lib/fastlane/actions/rsync.rb +3 -6
  137. data/fastlane/lib/fastlane/actions/run_tests.rb +1 -1
  138. data/fastlane/lib/fastlane/actions/s3.rb +1 -1
  139. data/fastlane/lib/fastlane/actions/say.rb +2 -3
  140. data/fastlane/lib/fastlane/actions/scp.rb +4 -10
  141. data/fastlane/lib/fastlane/actions/set_build_number_repository.rb +1 -1
  142. data/fastlane/lib/fastlane/actions/set_changelog.rb +10 -13
  143. data/fastlane/lib/fastlane/actions/set_github_release.rb +23 -16
  144. data/fastlane/lib/fastlane/actions/set_info_plist_value.rb +1 -1
  145. data/fastlane/lib/fastlane/actions/set_pod_key.rb +3 -4
  146. data/fastlane/lib/fastlane/actions/setup_ci.rb +1 -2
  147. data/fastlane/lib/fastlane/actions/setup_circle_ci.rb +1 -1
  148. data/fastlane/lib/fastlane/actions/setup_jenkins.rb +7 -12
  149. data/fastlane/lib/fastlane/actions/setup_travis.rb +1 -1
  150. data/fastlane/lib/fastlane/actions/sh.rb +2 -4
  151. data/fastlane/lib/fastlane/actions/slack.rb +164 -145
  152. data/fastlane/lib/fastlane/actions/slather.rb +5 -21
  153. data/fastlane/lib/fastlane/actions/sonar.rb +12 -19
  154. data/fastlane/lib/fastlane/actions/sourcedocs.rb +128 -0
  155. data/fastlane/lib/fastlane/actions/spaceship_logs.rb +1 -1
  156. data/fastlane/lib/fastlane/actions/splunkmint.rb +2 -2
  157. data/fastlane/lib/fastlane/actions/spm.rb +8 -2
  158. data/fastlane/lib/fastlane/actions/ssh.rb +5 -10
  159. data/fastlane/lib/fastlane/actions/swiftlint.rb +21 -19
  160. data/fastlane/lib/fastlane/actions/sync_code_signing.rb +6 -1
  161. data/fastlane/lib/fastlane/actions/testfairy.rb +0 -1
  162. data/fastlane/lib/fastlane/actions/tryouts.rb +2 -3
  163. data/fastlane/lib/fastlane/actions/twitter.rb +0 -5
  164. data/fastlane/lib/fastlane/actions/unlock_keychain.rb +3 -3
  165. data/fastlane/lib/fastlane/actions/update_app_group_identifiers.rb +1 -4
  166. data/fastlane/lib/fastlane/actions/update_code_signing_settings.rb +8 -15
  167. data/fastlane/lib/fastlane/actions/update_fastlane.rb +31 -10
  168. data/fastlane/lib/fastlane/actions/update_icloud_container_identifiers.rb +1 -4
  169. data/fastlane/lib/fastlane/actions/update_info_plist.rb +1 -1
  170. data/fastlane/lib/fastlane/actions/update_keychain_access_groups.rb +1 -4
  171. data/fastlane/lib/fastlane/actions/update_plist.rb +1 -1
  172. data/fastlane/lib/fastlane/actions/update_project_provisioning.rb +3 -4
  173. data/fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb +0 -1
  174. data/fastlane/lib/fastlane/actions/update_url_schemes.rb +15 -26
  175. data/fastlane/lib/fastlane/actions/upload_app_privacy_details_to_app_store.rb +290 -0
  176. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +8 -7
  177. data/fastlane/lib/fastlane/actions/upload_symbols_to_sentry.rb +3 -10
  178. data/fastlane/lib/fastlane/actions/upload_to_app_store.rb +8 -4
  179. data/fastlane/lib/fastlane/actions/upload_to_testflight.rb +7 -2
  180. data/fastlane/lib/fastlane/actions/validate_play_store_json_key.rb +40 -44
  181. data/fastlane/lib/fastlane/actions/version_get_podspec.rb +1 -2
  182. data/fastlane/lib/fastlane/actions/xcode_install.rb +8 -5
  183. data/fastlane/lib/fastlane/actions/xcode_server_get_assets.rb +3 -3
  184. data/fastlane/lib/fastlane/actions/xcodebuild.rb +5 -5
  185. data/fastlane/lib/fastlane/cli_tools_distributor.rb +6 -3
  186. data/fastlane/lib/fastlane/commands_generator.rb +2 -1
  187. data/fastlane/lib/fastlane/documentation/actions_list.rb +2 -2
  188. data/fastlane/lib/fastlane/documentation/docs_generator.rb +1 -1
  189. data/fastlane/lib/fastlane/documentation/markdown_docs_generator.rb +1 -1
  190. data/fastlane/lib/fastlane/environment_printer.rb +1 -0
  191. data/fastlane/lib/fastlane/erb_template_helper.rb +7 -1
  192. data/fastlane/lib/fastlane/fast_file.rb +19 -7
  193. data/fastlane/lib/fastlane/fastlane_require.rb +7 -1
  194. data/fastlane/lib/fastlane/features.rb +1 -1
  195. data/fastlane/lib/fastlane/helper/adb_helper.rb +1 -1
  196. data/fastlane/lib/fastlane/helper/crashlytics_helper.rb +4 -4
  197. data/fastlane/lib/fastlane/helper/gem_helper.rb +2 -2
  198. data/fastlane/lib/fastlane/helper/git_helper.rb +34 -5
  199. data/fastlane/lib/fastlane/lane_manager.rb +3 -2
  200. data/fastlane/lib/fastlane/notification/slack.rb +56 -0
  201. data/fastlane/lib/fastlane/plugins/plugin_fetcher.rb +1 -2
  202. data/fastlane/lib/fastlane/plugins/plugin_info.rb +2 -2
  203. data/fastlane/lib/fastlane/plugins/plugin_info_collector.rb +1 -2
  204. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +2 -3
  205. data/fastlane/lib/fastlane/plugins/template/%gem_name%.gemspec.erb +7 -6
  206. data/fastlane/lib/fastlane/plugins/template/.circleci/config.yml +1 -1
  207. data/fastlane/lib/fastlane/plugins/template/.github/workflows/test.yml +1 -1
  208. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +31 -35
  209. data/fastlane/lib/fastlane/plugins/template/spec/spec_helper.rb.erb +1 -1
  210. data/fastlane/lib/fastlane/setup/setup.rb +23 -10
  211. data/fastlane/lib/fastlane/setup/setup_ios.rb +3 -3
  212. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +3 -0
  213. data/fastlane/lib/fastlane/swift_fastlane_function.rb +44 -16
  214. data/fastlane/lib/fastlane/swift_runner_upgrader.rb +2 -0
  215. data/fastlane/lib/fastlane/version.rb +2 -2
  216. data/fastlane/swift/Actions.swift +1 -1
  217. data/fastlane/swift/Appfile.swift +1 -1
  218. data/fastlane/swift/ArgumentProcessor.swift +1 -1
  219. data/fastlane/swift/ControlCommand.swift +1 -1
  220. data/fastlane/swift/Deliverfile.swift +2 -2
  221. data/fastlane/swift/DeliverfileProtocol.swift +23 -23
  222. data/fastlane/swift/Fastfile.swift +1 -1
  223. data/fastlane/swift/Fastlane.swift +7965 -4213
  224. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.pbxproj +4 -0
  225. data/fastlane/swift/Gymfile.swift +2 -2
  226. data/fastlane/swift/GymfileProtocol.swift +15 -3
  227. data/fastlane/swift/LaneFileProtocol.swift +12 -6
  228. data/fastlane/swift/MainProcess.swift +3 -1
  229. data/fastlane/swift/Matchfile.swift +2 -2
  230. data/fastlane/swift/MatchfileProtocol.swift +4 -4
  231. data/fastlane/swift/OptionalConfigValue.swift +101 -0
  232. data/fastlane/swift/Plugins.swift +1 -1
  233. data/fastlane/swift/Precheckfile.swift +2 -2
  234. data/fastlane/swift/PrecheckfileProtocol.swift +8 -4
  235. data/fastlane/swift/RubyCommand.swift +2 -2
  236. data/fastlane/swift/RubyCommandable.swift +1 -1
  237. data/fastlane/swift/Runner.swift +3 -3
  238. data/fastlane/swift/RunnerArgument.swift +1 -1
  239. data/fastlane/swift/Scanfile.swift +2 -2
  240. data/fastlane/swift/ScanfileProtocol.swift +34 -2
  241. data/fastlane/swift/Screengrabfile.swift +2 -2
  242. data/fastlane/swift/ScreengrabfileProtocol.swift +5 -5
  243. data/fastlane/swift/Snapshotfile.swift +2 -2
  244. data/fastlane/swift/SnapshotfileProtocol.swift +19 -3
  245. data/fastlane/swift/SocketClient.swift +4 -3
  246. data/fastlane/swift/SocketClientDelegateProtocol.swift +1 -1
  247. data/fastlane/swift/SocketResponse.swift +5 -3
  248. data/fastlane/swift/formatting/Brewfile.lock.json +24 -16
  249. data/fastlane/swift/main.swift +1 -1
  250. data/fastlane/swift/upgrade_manifest.json +1 -1
  251. data/fastlane_core/lib/fastlane_core.rb +22 -20
  252. data/fastlane_core/lib/fastlane_core/build_watcher.rb +89 -12
  253. data/fastlane_core/lib/fastlane_core/cert_checker.rb +12 -7
  254. data/fastlane_core/lib/fastlane_core/clipboard.rb +20 -0
  255. data/fastlane_core/lib/fastlane_core/command_executor.rb +3 -9
  256. data/fastlane_core/lib/fastlane_core/configuration/commander_generator.rb +6 -1
  257. data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +41 -3
  258. data/fastlane_core/lib/fastlane_core/configuration/configuration.rb +14 -8
  259. data/fastlane_core/lib/fastlane_core/device_manager.rb +1 -1
  260. data/fastlane_core/lib/fastlane_core/helper.rb +78 -14
  261. data/fastlane_core/lib/fastlane_core/ipa_file_analyser.rb +41 -16
  262. data/fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb +3 -2
  263. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +20 -15
  264. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +1 -1
  265. data/fastlane_core/lib/fastlane_core/languages.rb +2 -2
  266. data/fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb +3 -2
  267. data/fastlane_core/lib/fastlane_core/print_table.rb +5 -3
  268. data/fastlane_core/lib/fastlane_core/project.rb +48 -28
  269. data/fastlane_core/lib/fastlane_core/provisioning_profile.rb +3 -1
  270. data/{deliver/lib/deliver → fastlane_core/lib/fastlane_core}/queue_worker.rb +4 -4
  271. data/fastlane_core/lib/fastlane_core/swag.rb +1 -1
  272. data/fastlane_core/lib/fastlane_core/ui/disable_colors.rb +8 -0
  273. data/fastlane_core/lib/fastlane_core/ui/help.erb +35 -0
  274. data/fastlane_core/lib/fastlane_core/ui/help_formatter.rb +16 -0
  275. data/fastlane_core/lib/fastlane_core/ui/implementations/shell.rb +16 -2
  276. data/fastlane_core/lib/fastlane_core/ui/interface.rb +1 -1
  277. data/fastlane_core/lib/fastlane_core/update_checker/update_checker.rb +2 -2
  278. data/frameit/lib/frameit/commands_generator.rb +2 -1
  279. data/frameit/lib/frameit/config_parser.rb +2 -2
  280. data/frameit/lib/frameit/device_types.rb +7 -1
  281. data/frameit/lib/frameit/frame_downloader.rb +2 -1
  282. data/gym/lib/gym/code_signing_mapping.rb +3 -3
  283. data/gym/lib/gym/commands_generator.rb +2 -1
  284. data/gym/lib/gym/error_handler.rb +8 -0
  285. data/gym/lib/gym/generators/build_command_generator.rb +3 -0
  286. data/gym/lib/gym/generators/package_command_generator.rb +4 -0
  287. data/gym/lib/gym/generators/package_command_generator_xcode7.rb +21 -15
  288. data/gym/lib/gym/options.rb +19 -3
  289. data/gym/lib/gym/runner.rb +15 -4
  290. data/match/lib/match/change_password.rb +3 -3
  291. data/match/lib/match/commands_generator.rb +2 -1
  292. data/match/lib/match/encryption/interface.rb +1 -1
  293. data/match/lib/match/encryption/openssl.rb +5 -3
  294. data/match/lib/match/importer.rb +9 -10
  295. data/match/lib/match/migrate.rb +2 -3
  296. data/match/lib/match/module.rb +2 -1
  297. data/match/lib/match/nuke.rb +19 -15
  298. data/match/lib/match/options.rb +4 -3
  299. data/match/lib/match/runner.rb +3 -4
  300. data/match/lib/match/spaceship_ensure.rb +3 -0
  301. data/match/lib/match/storage/git_storage.rb +14 -10
  302. data/match/lib/match/storage/google_cloud_storage.rb +2 -2
  303. data/match/lib/match/storage/s3_storage.rb +2 -2
  304. data/pem/lib/pem/commands_generator.rb +2 -1
  305. data/pilot/lib/pilot.rb +0 -1
  306. data/pilot/lib/pilot/build_manager.rb +41 -15
  307. data/pilot/lib/pilot/commands_generator.rb +2 -1
  308. data/pilot/lib/pilot/manager.rb +11 -8
  309. data/pilot/lib/pilot/options.rb +18 -9
  310. data/pilot/lib/pilot/tester_exporter.rb +0 -1
  311. data/pilot/lib/pilot/tester_manager.rb +0 -1
  312. data/precheck/lib/precheck/commands_generator.rb +2 -1
  313. data/precheck/lib/precheck/options.rb +9 -3
  314. data/precheck/lib/precheck/rule_processor.rb +1 -1
  315. data/precheck/lib/precheck/runner.rb +14 -9
  316. data/produce/lib/produce/commands_generator.rb +101 -28
  317. data/produce/lib/produce/developer_center.rb +42 -4
  318. data/produce/lib/produce/options.rb +1 -1
  319. data/produce/lib/produce/service.rb +270 -179
  320. data/scan/lib/scan/commands_generator.rb +2 -1
  321. data/scan/lib/scan/detect_values.rb +7 -2
  322. data/scan/lib/scan/module.rb +4 -0
  323. data/scan/lib/scan/options.rb +46 -1
  324. data/scan/lib/scan/runner.rb +88 -3
  325. data/scan/lib/scan/slack_poster.rb +4 -1
  326. data/scan/lib/scan/test_command_generator.rb +13 -8
  327. data/screengrab/lib/screengrab/android_environment.rb +5 -53
  328. data/screengrab/lib/screengrab/commands_generator.rb +2 -1
  329. data/screengrab/lib/screengrab/dependency_checker.rb +0 -20
  330. data/screengrab/lib/screengrab/options.rb +5 -2
  331. data/screengrab/lib/screengrab/runner.rb +111 -108
  332. data/sigh/lib/assets/resign.sh +81 -61
  333. data/sigh/lib/sigh/commands_generator.rb +2 -1
  334. data/sigh/lib/sigh/download_all.rb +4 -8
  335. data/sigh/lib/sigh/options.rb +3 -2
  336. data/sigh/lib/sigh/runner.rb +9 -9
  337. data/snapshot/lib/assets/SnapfileTemplate +3 -2
  338. data/snapshot/lib/assets/SnapfileTemplate.swift +2 -1
  339. data/snapshot/lib/assets/SnapshotHelper.swift +20 -12
  340. data/snapshot/lib/snapshot/commands_generator.rb +3 -1
  341. data/snapshot/lib/snapshot/options.rb +22 -2
  342. data/snapshot/lib/snapshot/reports_generator.rb +7 -1
  343. data/snapshot/lib/snapshot/simulator_launchers/launcher_configuration.rb +2 -0
  344. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher.rb +1 -1
  345. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +10 -5
  346. data/snapshot/lib/snapshot/test_command_generator.rb +18 -4
  347. data/snapshot/lib/snapshot/test_command_generator_base.rb +3 -1
  348. data/snapshot/lib/snapshot/test_command_generator_xcode_8.rb +1 -1
  349. data/snapshot/lib/snapshot/update.rb +1 -1
  350. data/spaceship/README.md +4 -14
  351. data/spaceship/lib/spaceship/base.rb +2 -2
  352. data/spaceship/lib/spaceship/client.rb +47 -29
  353. data/spaceship/lib/spaceship/commands_generator.rb +4 -2
  354. data/spaceship/lib/spaceship/connect_api.rb +6 -0
  355. data/spaceship/lib/spaceship/connect_api/api_client.rb +67 -9
  356. data/spaceship/lib/spaceship/connect_api/model.rb +1 -1
  357. data/spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb +39 -6
  358. data/spaceship/lib/spaceship/connect_api/models/app.rb +95 -55
  359. data/spaceship/lib/spaceship/connect_api/models/app_data_usage.rb +59 -0
  360. data/spaceship/lib/spaceship/connect_api/models/app_data_usage_category.rb +65 -0
  361. data/spaceship/lib/spaceship/connect_api/models/app_data_usage_data_protection.rb +27 -0
  362. data/spaceship/lib/spaceship/connect_api/models/app_data_usage_grouping.rb +18 -0
  363. data/spaceship/lib/spaceship/connect_api/models/app_data_usage_purposes.rb +37 -0
  364. data/spaceship/lib/spaceship/connect_api/models/app_data_usages_publish_state.rb +36 -0
  365. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +26 -10
  366. data/spaceship/lib/spaceship/connect_api/models/app_info_localization.rb +8 -4
  367. data/spaceship/lib/spaceship/connect_api/models/app_preview.rb +15 -11
  368. data/spaceship/lib/spaceship/connect_api/models/app_preview_set.rb +18 -9
  369. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +10 -8
  370. data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +20 -11
  371. data/spaceship/lib/spaceship/connect_api/models/app_store_review_attachment.rb +7 -5
  372. data/spaceship/lib/spaceship/connect_api/models/app_store_review_detail.rb +6 -4
  373. data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +62 -38
  374. data/spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb +27 -14
  375. data/spaceship/lib/spaceship/connect_api/models/app_store_version_submission.rb +3 -2
  376. data/spaceship/lib/spaceship/connect_api/models/beta_app_review_submission.rb +3 -2
  377. data/spaceship/lib/spaceship/connect_api/models/beta_feedback.rb +6 -4
  378. data/spaceship/lib/spaceship/connect_api/models/beta_group.rb +29 -3
  379. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +15 -9
  380. data/spaceship/lib/spaceship/connect_api/models/build.rb +34 -17
  381. data/spaceship/lib/spaceship/connect_api/models/build_beta_detail.rb +4 -0
  382. data/spaceship/lib/spaceship/connect_api/models/build_delivery.rb +3 -2
  383. data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +41 -6
  384. data/spaceship/lib/spaceship/connect_api/models/bundle_id_capability.rb +86 -21
  385. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +12 -8
  386. data/spaceship/lib/spaceship/connect_api/models/device.rb +36 -4
  387. data/spaceship/lib/spaceship/connect_api/models/idfa_declaration.rb +6 -4
  388. data/spaceship/lib/spaceship/connect_api/models/profile.rb +18 -8
  389. data/spaceship/lib/spaceship/connect_api/models/reset_ratings_request.rb +3 -2
  390. data/spaceship/lib/spaceship/connect_api/models/sandbox_tester.rb +9 -6
  391. data/spaceship/lib/spaceship/connect_api/models/territory.rb +3 -2
  392. data/spaceship/lib/spaceship/connect_api/models/user.rb +6 -4
  393. data/spaceship/lib/spaceship/connect_api/models/user_invitation.rb +22 -6
  394. data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +99 -2
  395. data/spaceship/lib/spaceship/connect_api/response.rb +3 -1
  396. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +50 -0
  397. data/spaceship/lib/spaceship/connect_api/token.rb +15 -3
  398. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +122 -2
  399. data/spaceship/lib/spaceship/errors.rb +19 -0
  400. data/spaceship/lib/spaceship/playground.rb +2 -2
  401. data/spaceship/lib/spaceship/spaceauth_runner.rb +38 -15
  402. data/spaceship/lib/spaceship/tunes/iap_detail.rb +1 -1
  403. data/spaceship/lib/spaceship/tunes/members.rb +1 -1
  404. data/spaceship/lib/spaceship/tunes/tunes_client.rb +4 -4
  405. data/spaceship/lib/spaceship/two_step_or_factor_client.rb +59 -33
  406. data/spaceship/lib/spaceship/ui.rb +2 -2
  407. data/spaceship/lib/spaceship/upgrade_2fa_later_client.rb +91 -0
  408. data/supply/lib/supply.rb +1 -1
  409. data/supply/lib/supply/client.rb +5 -3
  410. data/supply/lib/supply/commands_generator.rb +2 -1
  411. data/supply/lib/supply/options.rb +3 -3
  412. data/supply/lib/supply/uploader.rb +6 -4
  413. metadata +125 -93
  414. data/pilot/lib/pilot/features.rb +0 -0
  415. data/pilot/lib/pilot/tester_util.rb +0 -0
@@ -22,7 +22,8 @@ module Screengrab
22
22
  FastlaneCore::ConfigItem.new(key: :build_tools_version,
23
23
  short_option: "-i",
24
24
  optional: true,
25
- description: "The Android build tools version to use, e.g. '23.0.2'"),
25
+ description: "The Android build tools version to use, e.g. '23.0.2'",
26
+ deprecated: true),
26
27
  FastlaneCore::ConfigItem.new(key: :locales,
27
28
  description: "A list of locales which should be used",
28
29
  short_option: "-q",
@@ -82,10 +83,12 @@ module Screengrab
82
83
  env_name: 'SCREENGRAB_ENDING_LOCALE',
83
84
  optional: true,
84
85
  default_value: 'en-US',
85
- description: "Return the device to this locale after running tests"),
86
+ description: "Return the device to this locale after running tests",
87
+ deprecated: true),
86
88
  FastlaneCore::ConfigItem.new(key: :use_adb_root,
87
89
  env_name: 'SCREENGRAB_USE_ADB_ROOT',
88
90
  description: "Restarts the adb daemon using `adb root` to allow access to screenshots directories on device. Use if getting 'Permission denied' errors",
91
+ deprecated: true,
89
92
  default_value: false,
90
93
  type: Boolean),
91
94
  FastlaneCore::ConfigItem.new(key: :app_apk_path,
@@ -6,12 +6,6 @@ require_relative 'module'
6
6
 
7
7
  module Screengrab
8
8
  class Runner
9
- NEEDED_PERMISSIONS = [
10
- 'android.permission.READ_EXTERNAL_STORAGE',
11
- 'android.permission.WRITE_EXTERNAL_STORAGE',
12
- 'android.permission.CHANGE_CONFIGURATION'
13
- ].freeze
14
-
15
9
  attr_accessor :number_of_retries
16
10
 
17
11
  def initialize(executor = FastlaneCore::CommandExecutor,
@@ -24,6 +18,7 @@ module Screengrab
24
18
  end
25
19
 
26
20
  def run
21
+ # Standardize the locales
27
22
  FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [], title: "Summary for screengrab #{Fastlane::VERSION}")
28
23
 
29
24
  app_apk_path = @config.fetch(:app_apk_path, ask: false)
@@ -57,14 +52,14 @@ module Screengrab
57
52
  device_serial = select_device
58
53
 
59
54
  device_screenshots_paths = [
60
- determine_external_screenshots_path(device_serial, @config[:locales]),
61
- determine_internal_screenshots_paths(@config[:app_package_name], @config[:locales])
62
- ].flatten
55
+ determine_external_screenshots_path(device_serial, @config[:app_package_name], @config[:locales]),
56
+ determine_internal_screenshots_paths(device_serial, @config[:app_package_name], @config[:locales])
57
+ ].flatten(1)
63
58
 
64
59
  # Root is needed to access device paths at /data
65
60
  if @config[:use_adb_root]
66
- run_adb_command("-s #{device_serial} root", print_all: false, print_command: true)
67
- run_adb_command("-s #{device_serial} wait-for-device", print_all: false, print_command: true)
61
+ run_adb_command("-s #{device_serial.shellescape} root", print_all: false, print_command: true)
62
+ run_adb_command("-s #{device_serial.shellescape} wait-for-device", print_all: false, print_command: true)
68
63
  end
69
64
 
70
65
  clear_device_previous_screenshots(@config[:app_package_name], device_serial, device_screenshots_paths)
@@ -72,9 +67,7 @@ module Screengrab
72
67
  app_apk_path ||= select_app_apk(discovered_apk_paths)
73
68
  tests_apk_path ||= select_tests_apk(discovered_apk_paths)
74
69
 
75
- validate_apk(app_apk_path)
76
-
77
- number_of_screenshots = run_tests(device_type_dir_name, device_screenshots_paths, device_serial, app_apk_path, tests_apk_path, test_classes_to_use, test_packages_to_use, @config[:launch_arguments])
70
+ number_of_screenshots = run_tests(device_type_dir_name, device_serial, app_apk_path, tests_apk_path, test_classes_to_use, test_packages_to_use, @config[:launch_arguments])
78
71
 
79
72
  ReportsGenerator.new.generate
80
73
 
@@ -131,72 +124,71 @@ module Screengrab
131
124
  Dir.glob(File.join(output_directory, '**', device_type, '*.png'), File::FNM_CASEFOLD)
132
125
  end
133
126
 
134
- def determine_external_screenshots_path(device_serial, locales)
127
+ def get_device_environment_variable(device_serial, variable_name)
135
128
  # macOS evaluates $foo in `echo $foo` before executing the command,
136
129
  # Windows doesn't - hence the double backslash vs. single backslash
137
- command = Helper.windows? ? "shell echo \$EXTERNAL_STORAGE " : "shell echo \\$EXTERNAL_STORAGE"
138
- device_ext_storage = run_adb_command("-s #{device_serial} #{command}",
139
- print_all: true,
140
- print_command: true)
141
- device_ext_storage = device_ext_storage.strip
130
+ command = Helper.windows? ? "shell echo \$#{variable_name.shellescape.shellescape}" : "shell echo \\$#{variable_name.shellescape.shellescape}"
131
+ value = run_adb_command("-s #{device_serial.shellescape} #{command}",
132
+ print_all: true,
133
+ print_command: true)
134
+ return value.strip
135
+ end
136
+
137
+ # Don't need to use to use run-as if external
138
+ def use_adb_run_as?(path, device_serial)
139
+ device_ext_storage = get_device_environment_variable(device_serial, "EXTERNAL_STORAGE")
140
+ return !path.start_with?(device_ext_storage)
141
+ end
142
+
143
+ def determine_external_screenshots_path(device_serial, app_package_name, locales)
144
+ device_ext_storage = get_device_environment_variable(device_serial, "EXTERNAL_STORAGE")
142
145
  return locales.map do |locale|
143
- File.join(device_ext_storage, @config[:app_package_name], 'screengrab', locale, "images", "screenshots")
144
- end.flatten
146
+ [
147
+ File.join(device_ext_storage, app_package_name, 'screengrab', locale, "images", "screenshots"),
148
+ File.join(device_ext_storage, "Android", "data", app_package_name, 'files', 'screengrab', locale, "images", "screenshots")
149
+ ]
150
+ end.flatten.map { |path| [path, false] }
145
151
  end
146
152
 
147
- def determine_internal_screenshots_paths(app_package_name, locales)
153
+ def determine_internal_screenshots_paths(device_serial, app_package_name, locales)
154
+ device_data = get_device_environment_variable(device_serial, "ANDROID_DATA")
148
155
  return locales.map do |locale|
149
156
  [
150
- "/data/user/0/#{app_package_name}/files/#{app_package_name}/screengrab/#{locale}/images/screenshots",
157
+ "#{device_data}/user/0/#{app_package_name}/files/#{app_package_name}/screengrab/#{locale}/images/screenshots",
151
158
 
152
159
  # https://github.com/fastlane/fastlane/issues/15653#issuecomment-578541663
153
- "/data/data/#{app_package_name}/files/#{app_package_name}/screengrab/#{locale}/images/screenshots",
160
+ "#{device_data}/data/#{app_package_name}/files/#{app_package_name}/screengrab/#{locale}/images/screenshots",
154
161
 
155
- "/data/data/#{app_package_name}/app_screengrab/#{locale}/images/screenshots",
156
- "/data/data/#{app_package_name}/screengrab/#{locale}/images/screenshots"
162
+ "#{device_data}/data/#{app_package_name}/app_screengrab/#{locale}/images/screenshots",
163
+ "#{device_data}/data/#{app_package_name}/screengrab/#{locale}/images/screenshots"
157
164
  ]
158
- end.flatten
165
+ end.flatten.map { |path| [path, true] }
159
166
  end
160
167
 
161
168
  def clear_device_previous_screenshots(app_package_name, device_serial, device_screenshots_paths)
162
169
  UI.message('Cleaning screenshots on device')
163
170
 
164
- device_screenshots_paths.each do |device_path|
165
- if_device_path_exists(app_package_name, device_serial, device_path) do |path|
166
- run_adb_command("-s #{device_serial} shell run-as #{app_package_name} rm -rf #{path}",
171
+ device_screenshots_paths.each do |(device_path, needs_run_as)|
172
+ if_device_path_exists(app_package_name, device_serial, device_path, needs_run_as) do |path|
173
+ # Determine if path needs the run-as permission
174
+ run_as = needs_run_as ? " run-as #{app_package_name.shellescape.shellescape}" : ""
175
+
176
+ run_adb_command("-s #{device_serial.shellescape} shell#{run_as} rm -rf #{path.shellescape.shellescape}",
167
177
  print_all: true,
168
178
  print_command: true)
169
179
  end
170
180
  end
171
181
  end
172
182
 
173
- def validate_apk(app_apk_path)
174
- unless @android_env.aapt_path
175
- UI.important("The `aapt` command could not be found on your system, so your app APK could not be validated")
176
- return
177
- end
178
-
179
- UI.message('Validating app APK')
180
- apk_permissions = @executor.execute(command: "#{@android_env.aapt_path} dump permissions #{app_apk_path}",
181
- print_all: true,
182
- print_command: true)
183
-
184
- missing_permissions = NEEDED_PERMISSIONS.reject { |needed| apk_permissions.include?(needed) }
185
-
186
- if missing_permissions.any?
187
- UI.user_error!("The needed permission(s) #{missing_permissions.join(', ')} could not be found in your app APK")
188
- end
189
- end
190
-
191
183
  def install_apks(device_serial, app_apk_path, tests_apk_path)
192
184
  UI.message('Installing app APK')
193
- apk_install_output = run_adb_command("-s #{device_serial} install -t -r #{app_apk_path.shellescape}",
185
+ apk_install_output = run_adb_command("-s #{device_serial.shellescape} install -t -r #{app_apk_path.shellescape}",
194
186
  print_all: true,
195
187
  print_command: true)
196
188
  UI.user_error!("App APK could not be installed") if apk_install_output.include?("Failure [")
197
189
 
198
190
  UI.message('Installing tests APK')
199
- apk_install_output = run_adb_command("-s #{device_serial} install -t -r #{tests_apk_path.shellescape}",
191
+ apk_install_output = run_adb_command("-s #{device_serial.shellescape} install -t -r #{tests_apk_path.shellescape}",
200
192
  print_all: true,
201
193
  print_command: true)
202
194
  UI.user_error!("Tests APK could not be installed") if apk_install_output.include?("Failure [")
@@ -207,14 +199,14 @@ module Screengrab
207
199
 
208
200
  if packages.include?(app_package_name.to_s)
209
201
  UI.message('Uninstalling app APK')
210
- run_adb_command("-s #{device_serial} uninstall #{app_package_name}",
202
+ run_adb_command("-s #{device_serial.shellescape} uninstall #{app_package_name.shellescape}",
211
203
  print_all: true,
212
204
  print_command: true)
213
205
  end
214
206
 
215
207
  if packages.include?(tests_package_name.to_s)
216
208
  UI.message('Uninstalling tests APK')
217
- run_adb_command("-s #{device_serial} uninstall #{tests_package_name}",
209
+ run_adb_command("-s #{device_serial.shellescape} uninstall #{tests_package_name.shellescape}",
218
210
  print_all: true,
219
211
  print_command: true)
220
212
  end
@@ -222,26 +214,37 @@ module Screengrab
222
214
 
223
215
  def grant_permissions(device_serial)
224
216
  UI.message('Granting the permission necessary to change locales on the device')
225
- run_adb_command("-s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.CHANGE_CONFIGURATION",
217
+ run_adb_command("-s #{device_serial.shellescape} shell pm grant #{@config[:app_package_name].shellescape.shellescape} android.permission.CHANGE_CONFIGURATION",
226
218
  print_all: true,
227
- print_command: true)
219
+ print_command: true,
220
+ raise_errors: false)
228
221
 
229
- if device_api_version(device_serial) >= 23
230
- UI.message('Granting the permissions necessary to access device external storage')
231
- run_adb_command("-s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.WRITE_EXTERNAL_STORAGE",
232
- print_all: true,
233
- print_command: true)
234
- run_adb_command("-s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.READ_EXTERNAL_STORAGE",
235
- print_all: true,
236
- print_command: true)
237
- end
222
+ UI.message('Granting the permissions necessary to access device external storage')
223
+ run_adb_command("-s #{device_serial.shellescape} shell pm grant #{@config[:app_package_name].shellescape.shellescape} android.permission.WRITE_EXTERNAL_STORAGE",
224
+ print_all: true,
225
+ print_command: true,
226
+ raise_errors: false)
227
+ run_adb_command("-s #{device_serial.shellescape} shell pm grant #{@config[:app_package_name].shellescape.shellescape} android.permission.READ_EXTERNAL_STORAGE",
228
+ print_all: true,
229
+ print_command: true,
230
+ raise_errors: false)
231
+ end
232
+
233
+ def kill_app(device_serial, package_name)
234
+ run_adb_command("-s #{device_serial.shellescape} shell am force-stop #{package_name.shellescape.shellescape}.test",
235
+ print_all: true,
236
+ print_command: true)
237
+ run_adb_command("-s #{device_serial.shellescape} shell am force-stop #{package_name.shellescape.shellescape}",
238
+ print_all: true,
239
+ print_command: true)
238
240
  end
239
241
 
240
- def run_tests(device_type_dir_name, device_screenshots_paths, device_serial, app_apk_path, tests_apk_path, test_classes_to_use, test_packages_to_use, launch_arguments)
242
+ def run_tests(device_type_dir_name, device_serial, app_apk_path, tests_apk_path, test_classes_to_use, test_packages_to_use, launch_arguments)
243
+ sdk_version = device_api_version(device_serial)
241
244
  unless @config[:reinstall_app]
242
245
  install_apks(device_serial, app_apk_path, tests_apk_path)
243
246
  grant_permissions(device_serial)
244
- enable_clean_status_bar(device_serial, app_apk_path)
247
+ enable_clean_status_bar(device_serial, sdk_version)
245
248
  end
246
249
 
247
250
  number_of_screenshots = 0
@@ -251,25 +254,28 @@ module Screengrab
251
254
  uninstall_apks(device_serial, @config[:app_package_name], @config[:tests_package_name])
252
255
  install_apks(device_serial, app_apk_path, tests_apk_path)
253
256
  grant_permissions(device_serial)
254
- enable_clean_status_bar(device_serial, app_apk_path)
257
+ else
258
+ kill_app(device_serial, @config[:app_package_name])
255
259
  end
256
- number_of_screenshots += run_tests_for_locale(device_type_dir_name, device_screenshots_paths, locale, device_serial, test_classes_to_use, test_packages_to_use, launch_arguments)
260
+ number_of_screenshots += run_tests_for_locale(device_type_dir_name, locale, device_serial, test_classes_to_use, test_packages_to_use, launch_arguments, sdk_version)
257
261
  end
258
262
 
259
263
  number_of_screenshots
260
264
  end
261
265
 
262
- def run_tests_for_locale(device_type_dir_name, device_screenshots_paths, locale, device_serial, test_classes_to_use, test_packages_to_use, launch_arguments)
266
+ def run_tests_for_locale(device_type_dir_name, locale, device_serial, test_classes_to_use, test_packages_to_use, launch_arguments, sdk_version)
263
267
  UI.message("Running tests for locale: #{locale}")
264
268
 
265
- instrument_command = ["-s #{device_serial} shell am instrument --no-window-animation -w",
266
- "-e testLocale #{locale.tr('-', '_')}",
267
- "-e endingLocale #{@config[:ending_locale].tr('-', '_')}"]
269
+ instrument_command = ["-s #{device_serial.shellescape} shell am instrument --no-window-animation -w",
270
+ "-e testLocale #{locale.shellescape.shellescape}"]
271
+ if sdk_version >= 28
272
+ instrument_command << "--no-hidden-api-checks"
273
+ end
268
274
  instrument_command << "-e appendTimestamp #{@config[:use_timestamp_suffix]}"
269
- instrument_command << "-e class #{test_classes_to_use.join(',')}" if test_classes_to_use
270
- instrument_command << "-e package #{test_packages_to_use.join(',')}" if test_packages_to_use
275
+ instrument_command << "-e class #{test_classes_to_use.join(',').shellescape.shellescape}" if test_classes_to_use
276
+ instrument_command << "-e package #{test_packages_to_use.join(',').shellescape.shellescape}" if test_packages_to_use
271
277
  instrument_command << launch_arguments.map { |item| '-e ' + item }.join(' ') if launch_arguments
272
- instrument_command << "#{@config[:tests_package_name]}/#{@config[:test_instrumentation_runner]}"
278
+ instrument_command << "#{@config[:tests_package_name].shellescape.shellescape}/#{@config[:test_instrumentation_runner].shellescape.shellescape}"
273
279
 
274
280
  test_output = run_adb_command(instrument_command.join(" \\\n"),
275
281
  print_all: true,
@@ -283,30 +289,40 @@ module Screengrab
283
289
  end
284
290
  end
285
291
 
286
- pull_screenshots_from_device(locale, device_serial, device_screenshots_paths, device_type_dir_name)
292
+ pull_screenshots_from_device(locale, device_serial, device_type_dir_name)
287
293
  end
288
294
 
289
- def pull_screenshots_from_device(locale, device_serial, device_screenshots_paths, device_type_dir_name)
295
+ def pull_screenshots_from_device(locale, device_serial, device_type_dir_name)
290
296
  UI.message("Pulling captured screenshots for locale #{locale} from the device")
291
297
  starting_screenshot_count = screenshot_file_names_in(@config[:output_directory], device_type_dir_name).length
292
298
 
293
299
  UI.verbose("Starting screenshot count is: #{starting_screenshot_count}")
294
300
 
301
+ device_screenshots_paths = [
302
+ determine_external_screenshots_path(device_serial, @config[:app_package_name], [locale]),
303
+ determine_internal_screenshots_paths(device_serial, @config[:app_package_name], [locale])
304
+ ].flatten(1)
305
+
295
306
  # Make a temp directory into which to pull the screenshots before they are moved to their final location.
296
307
  # This makes directory cleanup easier, as the temp directory will be removed when the block completes.
297
308
 
298
309
  Dir.mktmpdir do |tempdir|
299
- device_screenshots_paths.each do |device_path|
300
- if_device_path_exists(@config[:app_package_name], device_serial, device_path) do |path|
310
+ device_screenshots_paths.each do |(device_path, needs_run_as)|
311
+ if_device_path_exists(@config[:app_package_name], device_serial, device_path, needs_run_as) do |path|
312
+ UI.message(path)
301
313
  next unless path.include?(locale)
302
- out = run_adb_command("-s #{device_serial} pull #{path} #{tempdir}",
314
+ out = run_adb_command("-s #{device_serial.shellescape} pull #{path.shellescape} #{tempdir.shellescape}",
303
315
  print_all: false,
304
316
  print_command: true,
305
317
  raise_errors: false)
306
318
  if out =~ /Permission denied/
307
319
  dir = File.dirname(path)
308
320
  base = File.basename(path)
309
- run_adb_command("-s #{device_serial} shell run-as #{@config[:app_package_name]} 'tar -cC #{dir} #{base}' | tar -xvC #{tempdir}",
321
+
322
+ # Determine if path needs the run-as permission
323
+ run_as = needs_run_as ? " run-as #{@config[:app_package_name].shellescape.shellescape}" : ""
324
+
325
+ run_adb_command("-s #{device_serial.shellescape} shell#{run_as} \"tar -cC #{dir} #{base}\" | tar -xv -f- -C #{tempdir}",
310
326
  print_all: false,
311
327
  print_command: true)
312
328
  end
@@ -370,8 +386,11 @@ module Screengrab
370
386
 
371
387
  # Some device commands fail if executed against a device path that does not exist, so this helper method
372
388
  # provides a way to conditionally execute a block only if the provided path exists on the device.
373
- def if_device_path_exists(app_package_name, device_serial, device_path)
374
- return if run_adb_command("-s #{device_serial} shell run-as #{app_package_name} ls #{device_path}",
389
+ def if_device_path_exists(app_package_name, device_serial, device_path, needs_run_as)
390
+ # Determine if path needs the run-as permission
391
+ run_as = needs_run_as ? " run-as #{app_package_name.shellescape.shellescape}" : ""
392
+
393
+ return if run_adb_command("-s #{device_serial.shellescape} shell#{run_as} ls #{device_path.shellescape.shellescape}",
375
394
  print_all: false,
376
395
  print_command: false).include?('No such file')
377
396
 
@@ -383,20 +402,19 @@ module Screengrab
383
402
 
384
403
  # Return an array of packages that are installed on the device
385
404
  def installed_packages(device_serial)
386
- packages = run_adb_command("-s #{device_serial} shell pm list packages",
405
+ packages = run_adb_command("-s #{device_serial.shellescape} shell pm list packages",
387
406
  print_all: true,
388
407
  print_command: true)
389
408
  packages.split("\n").map { |package| package.gsub("package:", "") }
390
409
  end
391
410
 
392
411
  def run_adb_command(command, print_all: false, print_command: false, raise_errors: true)
393
- adb_path = @android_env.adb_path.chomp("adb")
394
412
  adb_host = @config[:adb_host]
395
- host = adb_host.nil? ? '' : "-H #{adb_host} "
413
+ host = adb_host.nil? ? '' : "-H #{adb_host.shellescape} "
396
414
  output = ''
397
415
  begin
398
416
  errout = nil
399
- cmdout = @executor.execute(command: adb_path + "adb " + host + command,
417
+ cmdout = @executor.execute(command: @android_env.adb_path + " " + host + command,
400
418
  print_all: print_all,
401
419
  print_command: print_command,
402
420
  error: raise_errors ? nil : proc { |out, status| errout = out }) || ''
@@ -413,36 +431,21 @@ module Screengrab
413
431
  end
414
432
 
415
433
  def device_api_version(device_serial)
416
- run_adb_command("-s #{device_serial} shell getprop ro.build.version.sdk",
434
+ run_adb_command("-s #{device_serial.shellescape} shell getprop ro.build.version.sdk",
417
435
  print_all: true, print_command: true).to_i
418
436
  end
419
437
 
420
- def enable_clean_status_bar(device_serial, app_apk_path)
421
- return unless device_api_version(device_serial) >= 23
422
-
423
- unless @android_env.aapt_path
424
- UI.error("The `aapt` command could not be found, so status bar could not be cleaned. Make sure android_home is configured for screengrab or ANDROID_HOME is set in the environment")
425
- return
426
- end
427
-
428
- # Check if the app wants to use the clean status bar feature
429
- badging_dump = @executor.execute(command: "#{@android_env.aapt_path} dump badging #{app_apk_path}",
430
- print_all: true, print_command: true)
431
- return unless badging_dump.include?('uses-feature: name=\'tools.fastlane.screengrab.cleanstatusbar\'')
438
+ def enable_clean_status_bar(device_serial, sdk_version)
439
+ return unless sdk_version >= 23
432
440
 
433
441
  UI.message('Enabling clean status bar')
434
442
 
435
- # Make sure the app requests the DUMP permission
436
- unless badging_dump.include?('uses-permission: name=\'android.permission.DUMP\'')
437
- UI.user_error!("The clean status bar feature requires the android.permission.DUMP permission but it could not be found in your app APK")
438
- end
439
-
440
443
  # Grant the DUMP permission
441
- run_adb_command("-s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.DUMP",
442
- print_all: true, print_command: true)
444
+ run_adb_command("-s #{device_serial.shellescape} shell pm grant #{@config[:app_package_name].shellescape.shellescape} android.permission.DUMP",
445
+ print_all: true, print_command: true, raise_errors: false)
443
446
 
444
447
  # Enable the SystemUI demo mode
445
- run_adb_command("-s #{device_serial} shell settings put global sysui_demo_allowed 1",
448
+ run_adb_command("-s #{device_serial.shellescape} shell settings put global sysui_demo_allowed 1",
446
449
  print_all: true, print_command: true)
447
450
  end
448
451
  end
@@ -75,6 +75,11 @@
75
75
  # new features August 2020
76
76
  # 1. fixes usage for users with GNU-sed in their $PATH
77
77
  #
78
+ # new features May 2021
79
+ # 1. fix entitlements merging when changing team
80
+ #
81
+ # new features June 2021
82
+ # 1. fix the way app entitlements are extracted
78
83
 
79
84
  # Logging functions
80
85
 
@@ -346,7 +351,7 @@ function provision_for_bundle_id {
346
351
  }
347
352
 
348
353
  # Find the bundle identifier contained inside a provisioning profile
349
- function bundle_id_for_provison {
354
+ function bundle_id_for_provision {
350
355
 
351
356
  local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(security cms -D -i "$1")")
352
357
  checkStatus
@@ -384,7 +389,7 @@ function add_provision {
384
389
  error "Provisioning profile '$PROVISION' file does not exist"
385
390
  fi
386
391
 
387
- local BUNDLE_ID=$(bundle_id_for_provison "$PROVISION")
392
+ local BUNDLE_ID=$(bundle_id_for_provision "$PROVISION")
388
393
  add_provision_for_bundle_id "$PROVISION" "$BUNDLE_ID"
389
394
  }
390
395
 
@@ -434,7 +439,7 @@ function resign {
434
439
  error "Use the -p option (example: -p com.example.app=xxxx.mobileprovision)"
435
440
  fi
436
441
 
437
- local PROVISION_BUNDLE_IDENTIFIER=$(bundle_id_for_provison "$NEW_PROVISION")
442
+ local PROVISION_BUNDLE_IDENTIFIER=$(bundle_id_for_provision "$NEW_PROVISION")
438
443
 
439
444
  # Use provisioning profile's bundle identifier
440
445
  if [ "$BUNDLE_IDENTIFIER" == "" ]; then
@@ -580,7 +585,7 @@ function resign {
580
585
  # Found a reference bundle id, now get the corresponding provisioning profile for this bundle id
581
586
  REF_PROVISION=$(provision_for_bundle_id "$REF_BUNDLE_ID")
582
587
  # Map to the new bundle id
583
- NEW_REF_BUNDLE_ID=$(bundle_id_for_provison "$REF_PROVISION")
588
+ NEW_REF_BUNDLE_ID=$(bundle_id_for_provision "$REF_PROVISION")
584
589
  # Change if not the same and if doesn't contain wildcard
585
590
  # shellcheck disable=SC2049
586
591
  if [[ "$REF_BUNDLE_ID" != "$NEW_REF_BUNDLE_ID" ]] && ! [[ "$NEW_REF_BUNDLE_ID" =~ \* ]]; then
@@ -636,6 +641,20 @@ function resign {
636
641
  log "\nApp entitlements for ${APP_PATH}:"
637
642
  log "$(cat "$APP_ENTITLEMENTS")"
638
643
 
644
+ # Get the old and new app identifier (prefix)
645
+ APP_ID_KEY="application-identifier"
646
+ # Extract just the identifier from the value
647
+ # Use the fact that we are after some identifer, which is always at the start of the string
648
+ OLD_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$APP_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
649
+ NEW_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
650
+
651
+ # Get the old and the new team ID
652
+ # Old team ID is not part of app entitlements, have to get it from old embedded provisioning profile
653
+ security cms -D -i "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
654
+ OLD_TEAM_ID=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/old-embedded-profile.plist")
655
+ # New team ID is part of profile entitlements
656
+ NEW_TEAM_ID=$(PlistBuddy -c "Print com.apple.developer.team-identifier" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
657
+
639
658
  log "Patching profile entitlements with values from app entitlements"
640
659
  PATCHED_ENTITLEMENTS="$TEMP_DIR/patchedEntitlements"
641
660
  # Start with using what comes in provisioning profile entitlements before patching
@@ -654,20 +673,14 @@ function resign {
654
673
  "com.apple.developer.icloud-container-development-container-identifiers" \
655
674
  # This key has an invalid generic value in PP (actual value is set by Xcode during export), see dedicated processing a few blocks below
656
675
  "com.apple.developer.icloud-container-environment" \
657
- # PP list identifiers inconsistent with app-defined ones, must use App entitlements value
658
- "com.apple.developer.icloud-container-identifiers" \
659
676
  # PP enable all available services and not app-defined ones, must use App entitlements value
660
677
  "com.apple.developer.icloud-services" \
661
678
  # Was already denylisted in previous version, but has someone ever seen this key in a PP?
662
679
  "com.apple.developer.restricted-resource-mode" \
663
680
  # If actually used by the App, this value will be set in its entitlements
664
681
  "com.apple.developer.nfc.readersession.formats" \
665
- # PP list a single TeamID.* identifier and not app-defined ones, must use App entitlements value
666
- "com.apple.developer.pass-type-identifiers" \
667
682
  # If actually used by the App, this value will be set in its entitlements
668
683
  "com.apple.developer.siri" \
669
- # PP list identifiers inconsistent with app-defined ones, must use App entitlements value
670
- "com.apple.developer.ubiquity-container-identifiers" \
671
684
  # PP define a generic TeamID.* identifier and not the app-defined one, must use App entitlements value
672
685
  "com.apple.developer.ubiquity-kvstore-identifier" \
673
686
  # If actually used by the App, this value will be set in its entitlements
@@ -680,8 +693,6 @@ function resign {
680
693
  "com.apple.developer.healthkit" \
681
694
  # If actually used by the App, this value will be set in its entitlements
682
695
  "com.apple.developer.healthkit.access" \
683
- # PP list identifiers inconsistent with app-defined ones, must use App entitlements value
684
- "com.apple.developer.in-app-payments" \
685
696
  # If actually used by the App, this value will be set in its entitlements
686
697
  "com.apple.developer.networking.vpn.api" \
687
698
  # If actually used by the App, this value will be set in its entitlements
@@ -694,40 +705,45 @@ function resign {
694
705
  "com.apple.developer.associated-domains" \
695
706
  # If actually used by the App, this value will be set in its entitlements
696
707
  "com.apple.developer.default-data-protection" \
697
- # PP seem to list the same groups as the App, but use App entitlements value to be sure
698
- "com.apple.security.application-groups" \
699
708
  # Was already denylisted in previous version, seems to be an artifact from an old Xcode release
700
709
  "com.apple.developer.maps" \
701
710
  # If actually used by the App, this value will be set in its entitlements
702
711
  "com.apple.external-accessory.wireless-configuration"
703
712
  )
704
713
 
714
+ # If we change team while resigning, we have no other choice than to use the following entitlements from the PP instead of the App
715
+ # because they are based on unique identifiers (defined in the developer portal) that can't be shared between teams
716
+ if [[ "$OLD_TEAM_ID" != "$NEW_TEAM_ID" ]]; then
717
+ warning "WARNING: Changing team while resigning"
718
+ warning "WARNING: Using these entitlements from the provisioning profile instead of the existing app:"
719
+ warning "WARNING: App Groups, Merchant IDs (Apple Pay In-App Payments), iCloud Containers, Pass Type IDs (Wallet)"
720
+ warning "WARNING: If these capabilities are enabled, make sure AppID and provisioning profile are properly configured"
721
+ # For Pass Types, PP only list a single TeamID.* identifier and not the potential restricted list defined in the existing App
722
+ # but we can't guess the new identifiers to be used, so this generic value is better than nothing and should be fine for most apps
723
+ warning "WARNING: Resigned app will allow all pass types from the new team, even if old app only allowed a restricted list"
724
+ else
725
+ DENYLISTED_KEYS+=(\
726
+ "com.apple.security.application-groups" \
727
+ "com.apple.developer.in-app-payments" \
728
+ "com.apple.developer.ubiquity-container-identifiers" \
729
+ "com.apple.developer.icloud-container-identifiers" \
730
+ "com.apple.developer.pass-type-identifiers" \
731
+ )
732
+ fi
733
+
705
734
  # Denylisted keys must not be included into new profile, so remove them from patched profile
706
735
  for KEY in "${DENYLISTED_KEYS[@]}"; do
707
736
  log "Removing denylisted key: $KEY"
708
737
  PlistBuddy -c "Delete $KEY" "$PATCHED_ENTITLEMENTS" 2>/dev/null
709
738
  done
710
739
 
711
- # Get the old and new app identifier (prefix)
712
- APP_ID_KEY="application-identifier"
713
- # Extract just the identifier from the value
714
- # Use the fact that we are after some identifier, which is always at the start of the string
715
- OLD_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$APP_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
716
- NEW_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
717
-
718
- # Get the old and the new team ID
719
- # Old team ID is not part of app entitlements, have to get it from old embedded provisioning profile
720
- security cms -D -i "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
721
- OLD_TEAM_ID=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/old-embedded-profile.plist")
722
- # New team ID is part of profile entitlements
723
- NEW_TEAM_ID=$(PlistBuddy -c "Print com.apple.developer.team-identifier" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
724
-
725
740
  # List of rules for transferring entitlements from app to profile plist
726
741
  # The format for each enty is "KEY[|ID_TYPE]"
727
742
  # Where KEY is the plist key, e.g. "keychain-access-groups"
728
743
  # and ID_TYPE is optional part separated by '|' that specifies what value to patch:
729
744
  # TEAM_ID - patch the TeamIdentifierPrefix
730
745
  # APP_ID - patch the AppIdentifierPrefix
746
+ # ICLOUD_ENV - patch the target iCloud Environment
731
747
  # Patching means replacing old value from app entitlements with new value from provisioning profile
732
748
  # For example, for KEY=keychain-access-groups the ID_TYPE=APP_ID
733
749
  # Which means that old app ID prefix in keychain-access-groups will be replaced with new app ID prefix
@@ -740,23 +756,32 @@ function resign {
740
756
  "com.apple.developer.healthkit" \
741
757
  "com.apple.developer.healthkit.access" \
742
758
  "com.apple.developer.homekit" \
743
- "com.apple.developer.icloud-container-environment" \
744
- "com.apple.developer.icloud-container-identifiers" \
759
+ "com.apple.developer.icloud-container-environment|ICLOUD_ENV" \
745
760
  "com.apple.developer.icloud-services" \
746
- "com.apple.developer.in-app-payments" \
747
761
  "com.apple.developer.networking.HotspotConfiguration" \
748
762
  "com.apple.developer.networking.multipath" \
749
763
  "com.apple.developer.networking.networkextension" \
750
764
  "com.apple.developer.networking.vpn.api" \
751
765
  "com.apple.developer.nfc.readersession.formats" \
752
- "com.apple.developer.pass-type-identifiers|TEAM_ID" \
753
766
  "com.apple.developer.siri" \
754
- "com.apple.developer.ubiquity-container-identifiers" \
755
767
  "com.apple.developer.ubiquity-kvstore-identifier|TEAM_ID" \
756
768
  "com.apple.external-accessory.wireless-configuration" \
757
- "com.apple.security.application-groups" \
758
769
  "inter-app-audio" \
759
- "keychain-access-groups|APP_ID")
770
+ "keychain-access-groups|APP_ID" \
771
+ )
772
+
773
+ # If we change team while resigning, we have no other choice than to use the following entitlements from the PP instead of the App
774
+ # because they are based on unique identifiers (defined in the developer portal) that can't be shared between teams
775
+ # If we don't change team while resigning, we should use the following entitlements from the existing App and not from the PP
776
+ if [[ "$OLD_TEAM_ID" == "$NEW_TEAM_ID" ]]; then
777
+ ENTITLEMENTS_TRANSFER_RULES+=(\
778
+ "com.apple.security.application-groups" \
779
+ "com.apple.developer.in-app-payments" \
780
+ "com.apple.developer.ubiquity-container-identifiers" \
781
+ "com.apple.developer.icloud-container-identifiers" \
782
+ "com.apple.developer.pass-type-identifiers|TEAM_ID" \
783
+ )
784
+ fi
760
785
 
761
786
  # Loop over all the entitlement keys that need to be transferred from app entitlements
762
787
  for RULE in "${ENTITLEMENTS_TRANSFER_RULES[@]}"; do
@@ -765,13 +790,25 @@ function resign {
765
790
 
766
791
  # Get the entry from app's entitlements
767
792
  # Read it with PlistBuddy as XML, then strip the header and <plist></plist> part
768
- ENTITLEMENTS_VALUE="$(PlistBuddy -x -c "Print $KEY" "$APP_ENTITLEMENTS" 2>/dev/null | /usr/bin/sed -e 's,.*<plist[^>]*>\(.*\)</plist>,\1,g')"
793
+ ENTITLEMENTS_VALUE="$(PlistBuddy -x -c "Print $KEY" "$APP_ENTITLEMENTS" 2>/dev/null | tr -d '\n' | /usr/bin/sed -e 's,.*<plist[^>]*>\(.*\)</plist>,\1,g')"
769
794
  if [[ -z "$ENTITLEMENTS_VALUE" ]]; then
770
795
  log "No value for '$KEY'"
771
796
  continue
772
797
  fi
773
798
 
774
- if [[ "$KEY" == "com.apple.developer.icloud-container-environment" ]]; then
799
+ log "App entitlements value for key '$KEY':"
800
+ log "$ENTITLEMENTS_VALUE"
801
+
802
+ # Patch the ID value if specified
803
+ if [[ "$ID_TYPE" == "APP_ID" ]]; then
804
+ # Replace old value with new value in patched entitlements
805
+ log "Replacing old app ID '$OLD_APP_ID' with new app ID '$NEW_APP_ID'"
806
+ ENTITLEMENTS_VALUE=$(echo "$ENTITLEMENTS_VALUE" | /usr/bin/sed -e "s/$OLD_APP_ID/$NEW_APP_ID/g")
807
+ elif [[ "$ID_TYPE" == "TEAM_ID" ]]; then
808
+ # Replace old team identifier with new value
809
+ log "Replacing old team ID '$OLD_TEAM_ID' with new team ID '$NEW_TEAM_ID'"
810
+ ENTITLEMENTS_VALUE=$(echo "$ENTITLEMENTS_VALUE" | /usr/bin/sed -e "s/$OLD_TEAM_ID/$NEW_TEAM_ID/g")
811
+ elif [[ "$ID_TYPE" == "ICLOUD_ENV" ]]; then
775
812
  # Add specific iCloud Environment key to patched entitlements
776
813
  # This value is set by Xcode during export (manually selected for Development and AdHoc, automatically set to Production for Store)
777
814
  # Would need an additional dedicated option to specify the iCloud environment to be used (Development or Production)
@@ -788,20 +825,16 @@ function resign {
788
825
  fi
789
826
  fi
790
827
 
828
+ OLD_ICLOUD_ENV=$(echo "$ENTITLEMENTS_VALUE" | /usr/bin/sed -e 's,<string>\(.*\)</string>,\1,g')
791
829
  if [[ "$certificate_name" =~ "Distribution:" ]]; then
792
- ICLOUD_ENV="Production"
830
+ NEW_ICLOUD_ENV="Production"
793
831
  else
794
- ICLOUD_ENV="Development"
832
+ NEW_ICLOUD_ENV="Development"
795
833
  fi
796
- log "Overriding value for $KEY"
797
- log "Old value: $ENTITLEMENTS_VALUE"
798
- log "New value: $ICLOUD_ENV"
799
- ENTITLEMENTS_VALUE="$ICLOUD_ENV"
834
+ log "Replacing iCloud environment '$OLD_ICLOUD_ENV' with '$NEW_ICLOUD_ENV'"
835
+ ENTITLEMENTS_VALUE=$(echo "$ENTITLEMENTS_VALUE" | /usr/bin/sed -e "s/$OLD_ICLOUD_ENV/$NEW_ICLOUD_ENV/g")
800
836
  fi
801
837
 
802
- log "App entitlements value for key '$KEY':"
803
- log "$ENTITLEMENTS_VALUE"
804
-
805
838
  # Remove the entry for current key from profisioning profile entitlements (if exists)
806
839
  PlistBuddy -c "Delete $KEY" "$PATCHED_ENTITLEMENTS" 2>/dev/null
807
840
 
@@ -810,27 +843,14 @@ function resign {
810
843
  # otherwise it interprets they key path as nested keys
811
844
  # TODO: Should be able to replace with echo ${KEY//\./\\\\.} and remove shellcheck disable directive
812
845
  # shellcheck disable=SC2001
813
- PLUTIL_KEY=$(echo "$KEY" | /usr/bin/sed 's/\./\\\./g')
846
+ PLUTIL_KEY=$(echo "$KEY" | /usr/bin/sed -e 's/\./\\\./g')
814
847
  plutil -insert "$PLUTIL_KEY" -xml "$ENTITLEMENTS_VALUE" "$PATCHED_ENTITLEMENTS"
815
-
816
- # Patch the ID value if specified
817
- if [[ "$ID_TYPE" == "APP_ID" ]]; then
818
- # Replace old value with new value in patched entitlements
819
- log "Replacing old app identifier prefix '$OLD_APP_ID' with new value '$NEW_APP_ID'"
820
- /usr/bin/sed -i .bak "s/$OLD_APP_ID/$NEW_APP_ID/g" "$PATCHED_ENTITLEMENTS"
821
- elif [[ "$ID_TYPE" == "TEAM_ID" ]]; then
822
- # Replace old team identifier with new value
823
- log "Replacing old team ID '$OLD_TEAM_ID' with new team ID: '$NEW_TEAM_ID'"
824
- /usr/bin/sed -i .bak "s/$OLD_TEAM_ID/$NEW_TEAM_ID/g" "$PATCHED_ENTITLEMENTS"
825
- else
826
- continue
827
- fi
828
848
  done
829
849
 
830
850
  # Replace old bundle ID with new bundle ID in patched entitlements
831
851
  # Read old bundle ID from the old Info.plist which was saved for this purpose
832
852
  OLD_BUNDLE_ID="$(PlistBuddy -c "Print :CFBundleIdentifier" "$TEMP_DIR/oldInfo.plist")"
833
- NEW_BUNDLE_ID="$(bundle_id_for_provison "$NEW_PROVISION")"
853
+ NEW_BUNDLE_ID="$(bundle_id_for_provision "$NEW_PROVISION")"
834
854
  log "Replacing old bundle ID '$OLD_BUNDLE_ID' with new bundle ID '$NEW_BUNDLE_ID' in patched entitlements"
835
855
  # Note: ideally we'd match against the opening <string> tag too, but this isn't possible
836
856
  # because $OLD_BUNDLE_ID and $NEW_BUNDLE_ID do not include the team ID prefix which is