fastlane 2.9.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/cert/lib/cert/options.rb +11 -1
  4. data/cert/lib/cert/runner.rb +11 -3
  5. data/credentials_manager/lib/credentials_manager/account_manager.rb +1 -1
  6. data/credentials_manager/lib/credentials_manager/appfile_config.rb +2 -2
  7. data/fastlane/README.md +1 -1
  8. data/fastlane/lib/assets/completions/completion.bash +3 -1
  9. data/fastlane/lib/assets/completions/completion.sh +4 -1
  10. data/fastlane/lib/assets/completions/completion.zsh +2 -0
  11. data/fastlane/lib/fastlane/actions/actions_helper.rb +2 -2
  12. data/fastlane/lib/fastlane/actions/clipboard.rb +1 -1
  13. data/fastlane/lib/fastlane/actions/deploygate.rb +2 -2
  14. data/fastlane/lib/fastlane/actions/ipa.rb +2 -2
  15. data/fastlane/lib/fastlane/actions/sonar.rb +10 -3
  16. data/fastlane/lib/fastlane/actions/update_project_provisioning.rb +1 -1
  17. data/fastlane/lib/fastlane/actions/xcodebuild.rb +23 -6
  18. data/fastlane/lib/fastlane/documentation/docs_generator.rb +1 -1
  19. data/fastlane/lib/fastlane/fast_file.rb +2 -2
  20. data/fastlane/lib/fastlane/lane_manager.rb +5 -2
  21. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +2 -0
  22. data/fastlane/lib/fastlane/runner.rb +1 -1
  23. data/fastlane/lib/fastlane/version.rb +1 -1
  24. data/fastlane_core/lib/fastlane_core/cert_checker.rb +1 -1
  25. data/fastlane_core/lib/fastlane_core/configuration/configuration_file.rb +2 -2
  26. data/fastlane_core/lib/fastlane_core/print_table.rb +6 -0
  27. data/frameit/lib/frameit/strings_parser.rb +1 -1
  28. data/gym/lib/assets/wrap_xcodebuild/xcbuild-safe.sh +3 -0
  29. data/gym/lib/gym/generators/build_command_generator.rb +1 -0
  30. data/gym/lib/gym/options.rb +6 -1
  31. data/pem/README.md +1 -1
  32. data/scan/lib/scan/options.rb +14 -2
  33. data/scan/lib/scan/test_command_generator.rb +3 -2
  34. data/screengrab/lib/screengrab/options.rb +11 -1
  35. data/screengrab/lib/screengrab/runner.rb +48 -23
  36. data/sigh/lib/assets/resign.sh +75 -37
  37. data/sigh/lib/sigh/runner.rb +29 -9
  38. data/snapshot/lib/assets/SnapshotHelper.swift +4 -0
  39. data/snapshot/lib/assets/SnapshotHelper2-3.swift +4 -0
  40. data/snapshot/lib/snapshot/dependency_checker.rb +1 -1
  41. data/snapshot/lib/snapshot/options.rb +6 -0
  42. data/snapshot/lib/snapshot/runner.rb +15 -0
  43. data/spaceship/lib/spaceship/client.rb +1 -1
  44. data/spaceship/lib/spaceship/portal/certificate.rb +2 -1
  45. data/spaceship/lib/spaceship/portal/device.rb +3 -1
  46. data/spaceship/lib/spaceship/portal/portal_client.rb +2 -2
  47. data/spaceship/lib/spaceship/portal/provisioning_profile.rb +4 -2
  48. metadata +2 -2
@@ -1,4 +1,6 @@
1
1
  #!/bin/bash --login
2
+ # shellcheck disable=SC2155
3
+ # shellcheck disable=SC1090
2
4
 
3
5
  # Originally from, https://stackoverflow.com/questions/33041109
4
6
  # Modified to work in RVM and non RVM environments
@@ -21,6 +23,7 @@
21
23
  # -----
22
24
 
23
25
  which rvm > /dev/null
26
+ # shellcheck disable=SC2181
24
27
  if [[ $? -eq 0 ]]; then
25
28
  echo "RVM detected, forcing to use system ruby"
26
29
  # This allows you to use rvm in a script. Otherwise you get a BS
@@ -71,6 +71,7 @@ module Gym
71
71
  pipe << " --no-color" if Helper.colors_disabled?
72
72
  pipe << " --formatter " if formatter
73
73
  pipe << formatter if formatter
74
+ pipe << "--utf" if Gym.config[:xcpretty_utf]
74
75
  report_output_junit = Gym.config[:xcpretty_report_junit]
75
76
  report_output_html = Gym.config[:xcpretty_report_html]
76
77
  report_output_json = Gym.config[:xcpretty_report_json]
@@ -248,7 +248,12 @@ module Gym
248
248
  optional: true,
249
249
  verify_block: proc do |value|
250
250
  UI.user_error!("Report output location not found at path '#{File.expand_path(value)}'") unless File.exist?(value)
251
- end)
251
+ end),
252
+ FastlaneCore::ConfigItem.new(key: :xcpretty_utf,
253
+ env_name: "XCPRETTY_UTF",
254
+ description: "Have xcpretty use unicode encoding when reporting builds",
255
+ optional: true,
256
+ is_string: false)
252
257
  ]
253
258
  end
254
259
  end
data/pem/README.md CHANGED
@@ -114,7 +114,7 @@ To get a list of available options run:
114
114
  ### Note about empty `p12` passwords and Keychain Access.app
115
115
 
116
116
  `pem` will produce a valid `p12` without specifying a password, or using the empty-string as the password.
117
- While the file is valid, Mac OSX's Keychain Access will not allow you to open the file without specifying a passphrase.
117
+ While the file is valid, the Mac's Keychain Access will not allow you to open the file without specifying a passphrase.
118
118
 
119
119
  Instead, you may verify the file is valid using OpenSSL:
120
120
 
@@ -63,11 +63,23 @@ module Scan
63
63
  FastlaneCore::ConfigItem.new(key: :code_coverage,
64
64
  description: "Should generate code coverage (Xcode 7 only)?",
65
65
  is_string: false,
66
- default_value: false),
66
+ optional: true),
67
67
  FastlaneCore::ConfigItem.new(key: :address_sanitizer,
68
68
  description: "Should turn on the address sanitizer?",
69
69
  is_string: false,
70
- default_value: false),
70
+ optional: true,
71
+ conflicting_options: [:thread_sanitizer],
72
+ conflict_block: proc do |value|
73
+ UI.user_error!("You can't use 'address_sanitizer' and 'thread_sanitizer' options in one run")
74
+ end),
75
+ FastlaneCore::ConfigItem.new(key: :thread_sanitizer,
76
+ description: "Should turn on the thread sanitizer?",
77
+ is_string: false,
78
+ optional: true,
79
+ conflicting_options: [:address_sanitizer],
80
+ conflict_block: proc do |value|
81
+ UI.user_error!("You can't use 'thread_sanitizer' and 'address_sanitizer' options in one run")
82
+ end),
71
83
  FastlaneCore::ConfigItem.new(key: :skip_build,
72
84
  description: "Should skip debug build before test build?",
73
85
  short_option: "-r",
@@ -35,8 +35,9 @@ module Scan
35
35
  options << destination # generated in `detect_values`
36
36
  options << "-derivedDataPath '#{config[:derived_data_path]}'" if config[:derived_data_path]
37
37
  options << "-resultBundlePath '#{result_bundle_path}'" if config[:result_bundle]
38
- options << "-enableCodeCoverage YES" if config[:code_coverage]
39
- options << "-enableAddressSanitizer YES" if config[:address_sanitizer]
38
+ options << "-enableCodeCoverage #{config[:code_coverage] ? 'YES' : 'NO'}" unless config[:code_coverage].nil?
39
+ options << "-enableAddressSanitizer #{config[:address_sanitizer] ? 'YES' : 'NO'}" unless config[:address_sanitizer].nil?
40
+ options << "-enableThreadSanitizer #{config[:thread_sanitizer] ? 'YES' : 'NO'}" unless config[:thread_sanitizer].nil?
40
41
  options << "-xcconfig '#{config[:xcconfig]}'" if config[:xcconfig]
41
42
  options << config[:xcargs] if config[:xcargs]
42
43
 
@@ -61,6 +61,12 @@ module Screengrab
61
61
  short_option: "-l",
62
62
  type: Array,
63
63
  description: "Only run tests in these Java classes"),
64
+ FastlaneCore::ConfigItem.new(key: :launch_arguments,
65
+ env_name: 'SCREENGRAB_LAUNCH_ARGUMENTS',
66
+ optional: true,
67
+ short_option: "-e",
68
+ type: Array,
69
+ description: "Additional launch arguments"),
64
70
  FastlaneCore::ConfigItem.new(key: :test_instrumentation_runner,
65
71
  env_name: 'SCREENGRAB_TEST_INSTRUMENTATION_RUNNER',
66
72
  optional: true,
@@ -106,7 +112,11 @@ module Screengrab
106
112
  FastlaneCore::ConfigItem.new(key: :exit_on_test_failure,
107
113
  env_name: 'EXIT_ON_TEST_FAILURE',
108
114
  description: "Whether or not to exit Screengrab on test failure. Exiting on failure will not copy sceenshots to local machine nor open sceenshots summary",
109
- default_value: true)
115
+ default_value: true),
116
+ FastlaneCore::ConfigItem.new(key: :reinstall_app,
117
+ env_name: 'SCREENGRAB_REINSTALL_APP',
118
+ description: "Enabling this option will automatically uninstall the application before running it",
119
+ default_value: false)
110
120
  ]
111
121
  end
112
122
  end
@@ -63,11 +63,7 @@ module Screengrab
63
63
 
64
64
  validate_apk(app_apk_path)
65
65
 
66
- install_apks(device_serial, app_apk_path, tests_apk_path)
67
-
68
- grant_permissions(device_serial)
69
-
70
- run_tests(device_serial, test_classes_to_use, test_packages_to_use)
66
+ run_tests(device_serial, app_apk_path, tests_apk_path, test_classes_to_use, test_packages_to_use, @config[:launch_arguments])
71
67
 
72
68
  number_of_screenshots = pull_screenshots_from_device(device_serial, device_screenshots_paths, device_type_dir_name)
73
69
 
@@ -189,6 +185,20 @@ module Screengrab
189
185
  UI.user_error! "Tests APK could not be installed" if apk_install_output.include?("Failure [")
190
186
  end
191
187
 
188
+ def uninstall_apks(device_serial, app_package_name, tests_package_name)
189
+ UI.message 'Uninstalling app APK'
190
+ apk_uninstall_output = run_adb_command("adb -s #{device_serial} uninstall #{app_package_name}",
191
+ print_all: true,
192
+ print_command: true)
193
+ UI.user_error! "App APK could not be uninstalled" if apk_uninstall_output.include?("Failure [")
194
+
195
+ UI.message 'Uninstalling tests APK'
196
+ apk_uninstall_output = run_adb_command("adb -s #{device_serial} uninstall -r #{tests_package_name}",
197
+ print_all: true,
198
+ print_command: true)
199
+ UI.user_error! "Tests APK could not be uninstalled" if apk_uninstall_output.include?("Failure [")
200
+ end
201
+
192
202
  def grant_permissions(device_serial)
193
203
  UI.message 'Granting the permission necessary to change locales on the device'
194
204
  run_adb_command("adb -s #{device_serial} shell pm grant #{@config[:app_package_name]} android.permission.CHANGE_CONFIGURATION",
@@ -210,26 +220,41 @@ module Screengrab
210
220
  end
211
221
  end
212
222
 
213
- def run_tests(device_serial, test_classes_to_use, test_packages_to_use)
223
+ def run_tests(device_serial, app_apk_path, tests_apk_path, test_classes_to_use, test_packages_to_use, launch_arguments)
224
+ unless @config[:reinstall_app]
225
+ install_apks(device_serial, app_apk_path, tests_apk_path)
226
+ grant_permissions(device_serial)
227
+ end
228
+
214
229
  @config[:locales].each do |locale|
215
- UI.message "Running tests for locale: #{locale}"
216
-
217
- instrument_command = ["adb -s #{device_serial} shell am instrument --no-window-animation -w",
218
- "-e testLocale #{locale.tr('-', '_')}",
219
- "-e endingLocale #{@config[:ending_locale].tr('-', '_')}"]
220
- instrument_command << "-e class #{test_classes_to_use.join(',')}" if test_classes_to_use
221
- instrument_command << "-e package #{test_packages_to_use.join(',')}" if test_packages_to_use
222
- instrument_command << "#{@config[:tests_package_name]}/#{@config[:test_instrumentation_runner]}"
223
-
224
- test_output = run_adb_command(instrument_command.join(" \\\n"),
225
- print_all: true,
226
- print_command: true)
227
-
228
- if @config[:exit_on_test_failure]
229
- UI.user_error!("Tests failed", show_github_issues: false) if test_output.include?("FAILURES!!!")
230
- else
231
- UI.error("Tests failed") if test_output.include?("FAILURES!!!")
230
+ if @config[:reinstall_app]
231
+ uninstall_apks(device_serial, @config[:app_package_name], @config[:tests_package_name])
232
+ install_apks(device_serial, app_apk_path, tests_apk_path)
233
+ grant_permissions(device_serial)
232
234
  end
235
+ run_tests_for_locale(locale, device_serial, test_classes_to_use, test_packages_to_use, launch_arguments)
236
+ end
237
+ end
238
+
239
+ def run_tests_for_locale(locale, device_serial, test_classes_to_use, test_packages_to_use, launch_arguments)
240
+ UI.message "Running tests for locale: #{locale}"
241
+
242
+ instrument_command = ["adb -s #{device_serial} shell am instrument --no-window-animation -w",
243
+ "-e testLocale #{locale.tr('-', '_')}",
244
+ "-e endingLocale #{@config[:ending_locale].tr('-', '_')}"]
245
+ instrument_command << "-e class #{test_classes_to_use.join(',')}" if test_classes_to_use
246
+ instrument_command << "-e package #{test_packages_to_use.join(',')}" if test_packages_to_use
247
+ instrument_command << launch_arguments.map { |item| '-e ' + item }.join(' ') if launch_arguments
248
+ instrument_command << "#{@config[:tests_package_name]}/#{@config[:test_instrumentation_runner]}"
249
+
250
+ test_output = run_adb_command(instrument_command.join(" \\\n"),
251
+ print_all: true,
252
+ print_command: true)
253
+
254
+ if @config[:exit_on_test_failure]
255
+ UI.user_error!("Tests failed", show_github_issues: false) if test_output.include?("FAILURES!!!")
256
+ else
257
+ UI.error("Tests failed") if test_output.include?("FAILURES!!!")
233
258
  end
234
259
  end
235
260
 
@@ -1,4 +1,5 @@
1
1
  #!/bin/bash
2
+ # shellcheck disable=SC2155
2
3
 
3
4
  # Copyright (c) 2011 Float Mobile Learning
4
5
  # http://www.floatlearning.com/
@@ -65,7 +66,7 @@
65
66
  log() {
66
67
  # Make sure it returns 0 code even when verose mode is off (test 1)
67
68
  # To use like [[ condition ]] && log "x" && something
68
- [[ -n "$VERBOSE" ]] && echo -e "$@" || test 1
69
+ if [[ -n "$VERBOSE" ]]; then echo -e "$@"; else test 1; fi
69
70
  }
70
71
 
71
72
  error() {
@@ -79,6 +80,7 @@ warning() {
79
80
 
80
81
  function checkStatus {
81
82
 
83
+ # shellcheck disable=SC2181
82
84
  if [ $? -ne 0 ];
83
85
  then
84
86
  error "Encountered an error, aborting!"
@@ -86,7 +88,7 @@ function checkStatus {
86
88
  }
87
89
 
88
90
  usage() {
89
- echo -e "Usage: $(basename $0) source identity -p|--provisioning provisioning" >&2
91
+ echo -e "Usage: $(basename "$0") source identity -p|--provisioning provisioning" >&2
90
92
  echo -e "\t\t[-e|--entitlements entitlements]" >&2
91
93
  echo -e "\t\t[-k|--keychain keychain]" >&2
92
94
  echo -e "\t\t[-d|--display-name displayName]" >&2
@@ -96,7 +98,7 @@ usage() {
96
98
  echo -e "\t\t[-b|--bundle-id bundleId]" >&2
97
99
  echo -e "\t\t[--use-app-entitlements]" >&2
98
100
  echo -e "\t\toutputIpa" >&2
99
- echo "Usage: $(basename $0) -h|--help" >&2
101
+ echo "Usage: $(basename "$0") -h|--help" >&2
100
102
  echo "Options:" >&2
101
103
  echo -e "\t-p, --provisioning provisioning\t\tProvisioning profile option, may be provided multiple times." >&2
102
104
  echo -e "\t\t\t\t\t\tYou can specify provisioning profile file name." >&2
@@ -224,7 +226,7 @@ then
224
226
  fi
225
227
 
226
228
  # Log the options
227
- for provision in ${RAW_PROVISIONS[@]}; do
229
+ for provision in "${RAW_PROVISIONS[@]}"; do
228
230
  if [[ "$provision" =~ .+=.+ ]]; then
229
231
  log "Specified provisioning profile: '${provision#*=}' for bundle identifier: '${provision%%=*}'"
230
232
  else
@@ -291,15 +293,17 @@ fi
291
293
  # check the keychain
292
294
  if [ "${KEYCHAIN}" != "" ];
293
295
  then
294
- security list-keychains -s $KEYCHAIN
295
- security unlock $KEYCHAIN
296
- security default-keychain -s $KEYCHAIN
296
+ security list-keychains -s "$KEYCHAIN"
297
+ security unlock "$KEYCHAIN"
298
+ security default-keychain -s "$KEYCHAIN"
297
299
  fi
298
300
 
299
301
  # Set the app name
300
302
  # In Payload directory may be another file except .app file, such as StoreKit folder.
301
303
  # Search the first .app file within the Payload directory
302
- APP_NAME=$(ls "$TEMP_DIR/Payload/"|grep ".app$"| head -1)
304
+ # TODO: Replace with glob or call to 'find'; and remove shellcheck directive
305
+ # shellcheck disable=SC2010
306
+ APP_NAME=$(ls "$TEMP_DIR/Payload/" | grep ".app$" | head -1)
303
307
 
304
308
  # Make sure that PATH includes the location of the PlistBuddy helper tool as its location is not standard
305
309
  export PATH=$PATH:/usr/libexec
@@ -308,6 +312,7 @@ export PATH=$PATH:/usr/libexec
308
312
  # The first one may contain the wildcard character '*', in which case pattern matching will be used unless the third parameter is "STRICT"
309
313
  function does_bundle_id_match {
310
314
 
315
+ # shellcheck disable=SC2049
311
316
  if [[ "$1" == "$2" ]]; then
312
317
  return 0
313
318
  elif [[ "$3" != STRICT && "$1" =~ \* ]]; then
@@ -335,7 +340,7 @@ function provision_for_bundle_id {
335
340
  # Find the bundle identifier contained inside a provisioning profile
336
341
  function bundle_id_for_provison {
337
342
 
338
- local FULL_BUNDLE_ID=`PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< $(security cms -D -i "$1")`
343
+ local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(security cms -D -i "$1")")
339
344
  checkStatus
340
345
  echo "${FULL_BUNDLE_ID#*.}"
341
346
  }
@@ -346,7 +351,7 @@ function add_provision_for_bundle_id {
346
351
  local PROVISION="$1"
347
352
  local BUNDLE_ID="$2"
348
353
 
349
- local CURRENT_PROVISION=`provision_for_bundle_id "$BUNDLE_ID" STRICT`
354
+ local CURRENT_PROVISION=$(provision_for_bundle_id "$BUNDLE_ID" STRICT)
350
355
 
351
356
  if [[ "$CURRENT_PROVISION" != "" && "$CURRENT_PROVISION" != "$PROVISION" ]]; then
352
357
  error "Conflicting provisioning profiles '$PROVISION' and '$CURRENT_PROVISION' for bundle identifier '$BUNDLE_ID'."
@@ -371,7 +376,7 @@ function add_provision {
371
376
  error "Provisioning profile '$PROVISION' file does not exist"
372
377
  fi
373
378
 
374
- local BUNDLE_ID=`bundle_id_for_provison "$PROVISION"`
379
+ local BUNDLE_ID=$(bundle_id_for_provison "$PROVISION")
375
380
  add_provision_for_bundle_id "$PROVISION" "$BUNDLE_ID"
376
381
  }
377
382
 
@@ -405,9 +410,9 @@ function resign {
405
410
  cp -f "$APP_PATH/Info.plist" "$TEMP_DIR/oldInfo.plist"
406
411
 
407
412
  # Read in current values from the app
408
- local CURRENT_NAME=`PlistBuddy -c "Print :CFBundleDisplayName" "$APP_PATH/Info.plist"`
409
- local CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "$APP_PATH/Info.plist"`
410
- local NEW_PROVISION=`provision_for_bundle_id "${BUNDLE_IDENTIFIER:-$CURRENT_BUNDLE_IDENTIFIER}"`
413
+ local CURRENT_NAME=$(PlistBuddy -c "Print :CFBundleDisplayName" "$APP_PATH/Info.plist")
414
+ local CURRENT_BUNDLE_IDENTIFIER=$(PlistBuddy -c "Print :CFBundleIdentifier" "$APP_PATH/Info.plist")
415
+ local NEW_PROVISION=$(provision_for_bundle_id "${BUNDLE_IDENTIFIER:-$CURRENT_BUNDLE_IDENTIFIER}")
411
416
 
412
417
  if [[ "$NEW_PROVISION" == "" && "$NESTED" != NESTED ]]; then
413
418
  NEW_PROVISION="$DEFAULT_PROVISION"
@@ -422,10 +427,11 @@ function resign {
422
427
  error "Use the -p option (example: -p com.example.app=xxxx.mobileprovision)"
423
428
  fi
424
429
 
425
- local PROVISION_BUNDLE_IDENTIFIER=`bundle_id_for_provison "$NEW_PROVISION"`
430
+ local PROVISION_BUNDLE_IDENTIFIER=$(bundle_id_for_provison "$NEW_PROVISION")
426
431
 
427
432
  # Use provisioning profile's bundle identifier
428
433
  if [ "$BUNDLE_IDENTIFIER" == "" ]; then
434
+ # shellcheck disable=SC2049
429
435
  if [[ "$PROVISION_BUNDLE_IDENTIFIER" =~ \* ]]; then
430
436
  log "Bundle Identifier contains a *, using the current bundle identifier"
431
437
  BUNDLE_IDENTIFIER="$CURRENT_BUNDLE_IDENTIFIER"
@@ -447,7 +453,7 @@ function resign {
447
453
  if [ "${DISPLAY_NAME}" != "${CURRENT_NAME}" ];
448
454
  then
449
455
  log "Changing display name from '$CURRENT_NAME' to '$DISPLAY_NAME'"
450
- `PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "$APP_PATH/Info.plist"`
456
+ PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "$APP_PATH/Info.plist"
451
457
  fi
452
458
  fi
453
459
 
@@ -456,10 +462,10 @@ function resign {
456
462
  security cms -D -i "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
457
463
  checkStatus
458
464
 
459
- APP_IDENTIFIER_PREFIX=`PlistBuddy -c "Print :Entitlements:application-identifier" "$TEMP_DIR/profile.plist" | grep -E '^[A-Z0-9]*' -o | tr -d '\n'`
465
+ APP_IDENTIFIER_PREFIX=$(PlistBuddy -c "Print :Entitlements:application-identifier" "$TEMP_DIR/profile.plist" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
460
466
  if [ "$APP_IDENTIFIER_PREFIX" == "" ];
461
467
  then
462
- APP_IDENTIFIER_PREFIX=`PlistBuddy -c "Print :ApplicationIdentifierPrefix:0" "$TEMP_DIR/profile.plist"`
468
+ APP_IDENTIFIER_PREFIX=$(PlistBuddy -c "Print :ApplicationIdentifierPrefix:0" "$TEMP_DIR/profile.plist")
463
469
  if [ "$APP_IDENTIFIER_PREFIX" == "" ];
464
470
  then
465
471
  error "Failed to extract any app identifier prefix from '$NEW_PROVISION'"
@@ -473,10 +479,10 @@ function resign {
473
479
  # Set new app identifer prefix if such entry exists in plist file
474
480
  PlistBuddy -c "Set :AppIdentifierPrefix $APP_IDENTIFIER_PREFIX." "$APP_PATH/Info.plist" 2>/dev/null
475
481
 
476
- TEAM_IDENTIFIER=`PlistBuddy -c "Print :Entitlements:com.apple.developer.team-identifier" "$TEMP_DIR/profile.plist" | tr -d '\n'`
482
+ TEAM_IDENTIFIER=$(PlistBuddy -c "Print :Entitlements:com.apple.developer.team-identifier" "$TEMP_DIR/profile.plist" | tr -d '\n')
477
483
  if [ "$TEAM_IDENTIFIER" == "" ];
478
484
  then
479
- TEAM_IDENTIFIER=`PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/profile.plist"`
485
+ TEAM_IDENTIFIER=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/profile.plist")
480
486
  if [ "$TEAM_IDENTIFIER" == "" ];
481
487
  then
482
488
  warning "Failed to extract team identifier from '$NEW_PROVISION', resigned ipa may fail on iOS 8 and higher"
@@ -497,19 +503,19 @@ function resign {
497
503
  if [ "$CURRENT_BUNDLE_IDENTIFIER" != "$BUNDLE_IDENTIFIER" ];
498
504
  then
499
505
  log "Updating the bundle identifier from '$CURRENT_BUNDLE_IDENTIFIER' to '$BUNDLE_IDENTIFIER'"
500
- `PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "$APP_PATH/Info.plist"`
506
+ PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "$APP_PATH/Info.plist"
501
507
  checkStatus
502
508
  fi
503
509
 
504
510
  # Update the version number properties in the Info.plist if a version number has been provided
505
511
  if [ "$VERSION_NUMBER" != "" ];
506
512
  then
507
- CURRENT_VERSION_NUMBER=`PlistBuddy -c "Print :CFBundleVersion" "$APP_PATH/Info.plist"`
513
+ CURRENT_VERSION_NUMBER=$(PlistBuddy -c "Print :CFBundleVersion" "$APP_PATH/Info.plist")
508
514
  if [ "$VERSION_NUMBER" != "$CURRENT_VERSION_NUMBER" ];
509
515
  then
510
516
  log "Updating the version from '$CURRENT_VERSION_NUMBER' to '$VERSION_NUMBER'"
511
- `PlistBuddy -c "Set :CFBundleVersion $VERSION_NUMBER" "$APP_PATH/Info.plist"`
512
- `PlistBuddy -c "Set :CFBundleShortVersionString $VERSION_NUMBER" "$APP_PATH/Info.plist"`
517
+ PlistBuddy -c "Set :CFBundleVersion $VERSION_NUMBER" "$APP_PATH/Info.plist"
518
+ PlistBuddy -c "Set :CFBundleShortVersionString $VERSION_NUMBER" "$APP_PATH/Info.plist"
513
519
  fi
514
520
  fi
515
521
 
@@ -545,7 +551,7 @@ function resign {
545
551
  do
546
552
  if [[ "$framework" == *.framework || "$framework" == *.dylib ]]
547
553
  then
548
- /usr/bin/codesign ${VERBOSE} ${KEYCHAIN_FLAG} -f -s "$CERTIFICATE" "$framework"
554
+ /usr/bin/codesign ${VERBOSE} "${KEYCHAIN_FLAG}" -f -s "$CERTIFICATE" "$framework"
549
555
  checkStatus
550
556
  else
551
557
  log "Ignoring non-framework: $framework"
@@ -555,20 +561,21 @@ function resign {
555
561
 
556
562
  # Check for and update bundle identifiers for extensions and associated nested apps
557
563
  log "Fixing nested app and extension references"
558
- for key in ${NESTED_APP_REFERENCE_KEYS[@]}; do
564
+ for key in "${NESTED_APP_REFERENCE_KEYS[@]}"; do
559
565
  # Check if Info.plist has a reference to another app or extension
560
- REF_BUNDLE_ID=`PlistBuddy -c "Print ${key}" "$APP_PATH/Info.plist" 2>/dev/null`
566
+ REF_BUNDLE_ID=$(PlistBuddy -c "Print ${key}" "$APP_PATH/Info.plist" 2>/dev/null)
561
567
  if [ -n "$REF_BUNDLE_ID" ];
562
568
  then
563
569
  # Found a reference bundle id, now get the corresponding provisioning profile for this bundle id
564
- REF_PROVISION=`provision_for_bundle_id $REF_BUNDLE_ID`
570
+ REF_PROVISION=$(provision_for_bundle_id "$REF_BUNDLE_ID")
565
571
  # Map to the new bundle id
566
- NEW_REF_BUNDLE_ID=`bundle_id_for_provison "$REF_PROVISION"`
572
+ NEW_REF_BUNDLE_ID=$(bundle_id_for_provison "$REF_PROVISION")
567
573
  # Change if not the same and if doesn't contain wildcard
574
+ # shellcheck disable=SC2049
568
575
  if [[ "$REF_BUNDLE_ID" != "$NEW_REF_BUNDLE_ID" ]] && ! [[ "$NEW_REF_BUNDLE_ID" =~ \* ]];
569
576
  then
570
577
  log "Updating nested app or extension reference for ${key} key from ${REF_BUNDLE_ID} to ${NEW_REF_BUNDLE_ID}"
571
- `PlistBuddy -c "Set ${key} $NEW_REF_BUNDLE_ID" "$APP_PATH/Info.plist"`
578
+ PlistBuddy -c "Set ${key} $NEW_REF_BUNDLE_ID" "$APP_PATH/Info.plist"
572
579
  fi
573
580
  fi
574
581
  done
@@ -578,7 +585,7 @@ function resign {
578
585
  if [ -n "$APP_IDENTIFIER_PREFIX" ];
579
586
  then
580
587
  # sanity check the 'application-identifier' is present in the provided entitlements and matches the provisioning profile value
581
- ENTITLEMENTS_APP_ID_PREFIX=`PlistBuddy -c "Print :application-identifier" "$ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n'`
588
+ ENTITLEMENTS_APP_ID_PREFIX=$(PlistBuddy -c "Print :application-identifier" "$ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
582
589
  if [ "$ENTITLEMENTS_APP_ID_PREFIX" == "" ];
583
590
  then
584
591
  error "Provided entitlements file is missing a value for the required 'application-identifier' key"
@@ -591,7 +598,7 @@ function resign {
591
598
  if [ -n "$TEAM_IDENTIFIER" ];
592
599
  then
593
600
  # sanity check the 'com.apple.developer.team-identifier' is present in the provided entitlements and matches the provisioning profile value
594
- ENTITLEMENTS_TEAM_IDENTIFIER=`PlistBuddy -c "Print :com.apple.developer.team-identifier" "$ENTITLEMENTS" | tr -d '\n'`
601
+ ENTITLEMENTS_TEAM_IDENTIFIER=$(PlistBuddy -c "Print :com.apple.developer.team-identifier" "$ENTITLEMENTS" | tr -d '\n')
595
602
  if [ "$ENTITLEMENTS_TEAM_IDENTIFIER" == "" ];
596
603
  then
597
604
  error "Provided entitlements file is missing a value for the required 'com.apple.developer.team-identifier' key"
@@ -670,9 +677,9 @@ function resign {
670
677
  "keychain-access-groups|APP_ID")
671
678
 
672
679
  # Loop over all the entitlement keys that need to be transferred from app entitlements
673
- for RULE in ${ENTITLEMENTS_TRANSFER_RULES[@]}; do
674
- KEY=$(echo $RULE | cut -d'|' -f1)
675
- ID_TYPE=$(echo $RULE | cut -d'|' -f2)
680
+ for RULE in "${ENTITLEMENTS_TRANSFER_RULES[@]}"; do
681
+ KEY=$(echo "$RULE" | cut -d'|' -f1)
682
+ ID_TYPE=$(echo "$RULE" | cut -d'|' -f2)
676
683
 
677
684
  # Get the entry from app's entitlements
678
685
  # Read it with PlistBuddy as XML, then strip the header and <plist></plist> part
@@ -691,7 +698,9 @@ function resign {
691
698
  # Add new entry to patched entitlements
692
699
  # plutil needs dots in the key path to be escaped (e.g. com\.apple\.security\.application-groups)
693
700
  # otherwise it interprets they key path as nested keys
694
- PLUTIL_KEY=`echo "$KEY" | sed 's/\./\\\\./g'`
701
+ # TODO: Should be able to replace with echo ${KEY//\./\\\\.} and remove shellcheck disable directive
702
+ # shellcheck disable=SC2001
703
+ PLUTIL_KEY=$(echo "$KEY" | sed 's/\./\\\\./g')
695
704
  plutil -insert "$PLUTIL_KEY" -xml "$ENTITLEMENTS_VALUE" "$PATCHED_ENTITLEMENTS"
696
705
 
697
706
  # Patch the ID value if specified
@@ -715,6 +724,33 @@ function resign {
715
724
  log "Replacing old bundle ID '$OLD_BUNDLE_ID' with new bundle ID '$NEW_BUNDLE_ID' in patched entitlements"
716
725
  sed -i .bak "s/$OLD_BUNDLE_ID/$NEW_BUNDLE_ID/g" "$PATCHED_ENTITLEMENTS"
717
726
 
727
+ log "Removing blacklisted keys from patched profile"
728
+ # See https://github.com/facebook/buck/issues/798 and https://github.com/facebook/buck/pull/802/files
729
+ BLACKLISTED_KEYS=(\
730
+ "com.apple.developer.icloud-container-development-container-identifiers" \
731
+ "com.apple.developer.icloud-container-environment" \
732
+ "com.apple.developer.icloud-container-identifiers" \
733
+ "com.apple.developer.icloud-services" \
734
+ "com.apple.developer.restricted-resource-mode" \
735
+ "com.apple.developer.ubiquity-container-identifiers" \
736
+ "com.apple.developer.ubiquity-kvstore-identifier" \
737
+ "inter-app-audio" \
738
+ "com.apple.developer.homekit" \
739
+ "com.apple.developer.healthkit" \
740
+ "com.apple.developer.in-app-payments" \
741
+ "com.apple.developer.associated-domains" \
742
+ "com.apple.security.application-groups" \
743
+ "com.apple.developer.maps" \
744
+ "com.apple.developer.networking.vpn.api" \
745
+ "com.apple.external-accessory.wireless-configuration"
746
+ )
747
+
748
+ # Blacklisted keys must not be included into new profile, so remove them from patched profile
749
+ for KEY in "${BLACKLISTED_KEYS[@]}"; do
750
+ log "Removing blacklisted key: $KEY"
751
+ PlistBuddy -c "Delete $KEY" "$PATCHED_ENTITLEMENTS" 2>/dev/null
752
+ done
753
+
718
754
  log "Resigning application using certificate: '$CERTIFICATE'"
719
755
  log "and patched entitlements:"
720
756
  log "$(cat "$PATCHED_ENTITLEMENTS")"
@@ -728,7 +764,7 @@ function resign {
728
764
  log "Resigning application using certificate: '$CERTIFICATE'"
729
765
  log "and entitlements from provisioning profile: $NEW_PROVISION"
730
766
  cp -- "$TEMP_DIR/newEntitlements" "$APP_PATH/archived-expanded-entitlements.xcent"
731
- /usr/bin/codesign ${VERBOSE} ${KEYCHAIN_FLAG} -f -s "$CERTIFICATE" --entitlements "$TEMP_DIR/newEntitlements" "$APP_PATH"
767
+ /usr/bin/codesign ${VERBOSE} "${KEYCHAIN_FLAG}" -f -s "$CERTIFICATE" --entitlements "$TEMP_DIR/newEntitlements" "$APP_PATH"
732
768
  checkStatus
733
769
  fi
734
770
 
@@ -762,6 +798,8 @@ log "Repackaging as $NEW_FILE"
762
798
  # Zip all the contents, saving the zip file in the above directory
763
799
  # Navigate back to the orignating directory (sending the output to null)
764
800
  pushd "$TEMP_DIR" > /dev/null
801
+ # TODO: Fix shellcheck warning and remove directive
802
+ # shellcheck disable=SC2035
765
803
  zip -qry "../$TEMP_DIR.ipa" *
766
804
  popd > /dev/null
767
805