fastlane 2.139.0 → 2.144.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +85 -72
  4. data/cert/lib/cert/options.rb +12 -5
  5. data/cert/lib/cert/runner.rb +13 -0
  6. data/deliver/lib/deliver/options.rb +28 -2
  7. data/deliver/lib/deliver/runner.rb +13 -2
  8. data/fastlane/lib/fastlane/action.rb +1 -1
  9. data/fastlane/lib/fastlane/actions/.hockey.rb.swp +0 -0
  10. data/fastlane/lib/fastlane/actions/.slack.rb.swp +0 -0
  11. data/fastlane/lib/fastlane/actions/.update_project_provisioning.rb.swp +0 -0
  12. data/fastlane/lib/fastlane/actions/README.md +2 -0
  13. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +13 -5
  14. data/fastlane/lib/fastlane/actions/automatic_code_signing.rb +7 -1
  15. data/fastlane/lib/fastlane/actions/build_app.rb +157 -6
  16. data/fastlane/lib/fastlane/actions/build_ios_app.rb +28 -132
  17. data/fastlane/lib/fastlane/actions/build_mac_app.rb +46 -0
  18. data/fastlane/lib/fastlane/actions/clean_build_artifacts.rb +3 -0
  19. data/fastlane/lib/fastlane/actions/cocoapods.rb +2 -2
  20. data/fastlane/lib/fastlane/actions/crashlytics.rb +14 -2
  21. data/fastlane/lib/fastlane/actions/create_pull_request.rb +29 -0
  22. data/fastlane/lib/fastlane/actions/docs/{build_ios_app.md → build_app.md} +1 -1
  23. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +22 -6
  24. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +22 -6
  25. data/fastlane/lib/fastlane/actions/ensure_git_branch.rb +1 -1
  26. data/fastlane/lib/fastlane/actions/ensure_xcode_version.rb +35 -7
  27. data/fastlane/lib/fastlane/actions/frame_screenshots.rb +2 -1
  28. data/fastlane/lib/fastlane/actions/get_github_release.rb +3 -0
  29. data/fastlane/lib/fastlane/actions/gradle.rb +43 -2
  30. data/fastlane/lib/fastlane/actions/gym.rb +3 -7
  31. data/fastlane/lib/fastlane/actions/import_from_git.rb +4 -0
  32. data/fastlane/lib/fastlane/actions/latest_testflight_build_number.rb +9 -3
  33. data/fastlane/lib/fastlane/actions/notarize.rb +183 -0
  34. data/fastlane/lib/fastlane/actions/pod_lib_lint.rb +7 -1
  35. data/fastlane/lib/fastlane/actions/run_tests.rb +5 -22
  36. data/fastlane/lib/fastlane/actions/s3.rb +5 -291
  37. data/fastlane/lib/fastlane/actions/set_github_release.rb +1 -1
  38. data/fastlane/lib/fastlane/actions/spm.rb +8 -0
  39. data/fastlane/lib/fastlane/actions/swiftlint.rb +45 -9
  40. data/fastlane/lib/fastlane/actions/update_code_signing_settings.rb +190 -0
  41. data/fastlane/lib/fastlane/actions/update_plist.rb +37 -2
  42. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +13 -3
  43. data/fastlane/lib/fastlane/actions/upload_to_app_store.rb +1 -0
  44. data/fastlane/lib/fastlane/fast_file.rb +13 -3
  45. data/fastlane/lib/fastlane/helper/adb_helper.rb +1 -1
  46. data/fastlane/lib/fastlane/helper/s3_client_helper.rb +56 -0
  47. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +1 -1
  48. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +2 -0
  49. data/fastlane/lib/fastlane/runner.rb +23 -18
  50. data/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb +1 -1
  51. data/fastlane/lib/fastlane/version.rb +1 -1
  52. data/fastlane/swift/Deliverfile.swift +1 -1
  53. data/fastlane/swift/DeliverfileProtocol.swift +3 -3
  54. data/fastlane/swift/Fastlane.swift +422 -45
  55. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  56. data/fastlane/swift/Gymfile.swift +1 -1
  57. data/fastlane/swift/GymfileProtocol.swift +17 -1
  58. data/fastlane/swift/Matchfile.swift +1 -1
  59. data/fastlane/swift/MatchfileProtocol.swift +23 -3
  60. data/fastlane/swift/Precheckfile.swift +1 -1
  61. data/fastlane/swift/RubyCommand.swift +1 -1
  62. data/fastlane/swift/Scanfile.swift +1 -1
  63. data/fastlane/swift/ScanfileProtocol.swift +21 -1
  64. data/fastlane/swift/Screengrabfile.swift +1 -1
  65. data/fastlane/swift/Snapshotfile.swift +1 -1
  66. data/fastlane/swift/SnapshotfileProtocol.swift +9 -1
  67. data/fastlane_core/lib/fastlane_core/cert_checker.rb +28 -0
  68. data/fastlane_core/lib/fastlane_core/device_manager.rb +1 -1
  69. data/fastlane_core/lib/fastlane_core/ipa_file_analyser.rb +1 -0
  70. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +2 -0
  71. data/fastlane_core/lib/fastlane_core/project.rb +27 -0
  72. data/fastlane_core/lib/fastlane_core/provisioning_profile.rb +15 -2
  73. data/frameit/lib/frameit/commands_generator.rb +25 -0
  74. data/frameit/lib/frameit/config_parser.rb +31 -9
  75. data/frameit/lib/frameit/device.rb +90 -0
  76. data/frameit/lib/frameit/device_types.rb +121 -5
  77. data/frameit/lib/frameit/editor.rb +28 -40
  78. data/frameit/lib/frameit/offsets.rb +8 -1
  79. data/frameit/lib/frameit/options.rb +81 -54
  80. data/frameit/lib/frameit/runner.rb +17 -7
  81. data/frameit/lib/frameit/screenshot.rb +35 -47
  82. data/frameit/lib/frameit/template_finder.rb +15 -12
  83. data/gym/lib/gym/code_signing_mapping.rb +32 -3
  84. data/gym/lib/gym/detect_values.rb +34 -2
  85. data/gym/lib/gym/generators/package_command_generator.rb +8 -0
  86. data/gym/lib/gym/generators/package_command_generator_xcode7.rb +52 -17
  87. data/gym/lib/gym/module.rb +8 -0
  88. data/gym/lib/gym/options.rb +25 -1
  89. data/gym/lib/gym/runner.rb +70 -21
  90. data/match/lib/match/change_password.rb +1 -1
  91. data/match/lib/match/encryption.rb +4 -0
  92. data/match/lib/match/encryption/openssl.rb +1 -1
  93. data/match/lib/match/generator.rb +17 -3
  94. data/match/lib/match/importer.rb +35 -20
  95. data/match/lib/match/module.rb +5 -2
  96. data/match/lib/match/nuke.rb +59 -17
  97. data/match/lib/match/options.rb +38 -15
  98. data/match/lib/match/runner.rb +24 -8
  99. data/match/lib/match/setup.rb +1 -1
  100. data/match/lib/match/spaceship_ensure.rb +19 -9
  101. data/match/lib/match/storage.rb +4 -0
  102. data/match/lib/match/storage/git_storage.rb +5 -2
  103. data/match/lib/match/storage/google_cloud_storage.rb +2 -2
  104. data/match/lib/match/storage/s3_storage.rb +162 -0
  105. data/pilot/lib/pilot/.manager.rb.swp +0 -0
  106. data/pilot/lib/pilot/build_manager.rb +24 -9
  107. data/scan/lib/scan/detect_values.rb +6 -1
  108. data/scan/lib/scan/manager.rb +18 -1
  109. data/scan/lib/scan/options.rb +28 -1
  110. data/scan/lib/scan/runner.rb +9 -7
  111. data/scan/lib/scan/slack_poster.rb +1 -1
  112. data/scan/lib/scan/test_command_generator.rb +12 -5
  113. data/screengrab/lib/screengrab/runner.rb +31 -18
  114. data/sigh/lib/sigh/.runner.rb.swp +0 -0
  115. data/snapshot/lib/snapshot/fixes/simulator_shared_pasteboard.rb +16 -0
  116. data/snapshot/lib/snapshot/options.rb +12 -1
  117. data/snapshot/lib/snapshot/simulator_launchers/launcher_configuration.rb +2 -0
  118. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +13 -0
  119. data/spaceship/lib/spaceship/connect_api/.DS_Store +0 -0
  120. data/spaceship/lib/spaceship/connect_api/models/.bundle_id.rb.swp +0 -0
  121. data/{gym/lib/gym/.runner.rb.swp → spaceship/lib/spaceship/connect_api/models/.bundle_id_capability.rb.swp} +0 -0
  122. data/spaceship/lib/spaceship/connect_api/models/app.rb +11 -0
  123. data/spaceship/lib/spaceship/connect_api/models/beta_feedback.rb +4 -0
  124. data/spaceship/lib/spaceship/connect_api/models/build.rb +1 -2
  125. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +2 -0
  126. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +29 -0
  127. data/spaceship/lib/spaceship/portal/app.rb +11 -2
  128. data/spaceship/lib/spaceship/tunes/app_version.rb +6 -1
  129. data/spaceship/lib/spaceship/tunes/iap.rb +11 -11
  130. data/spaceship/lib/spaceship/tunes/iap_detail.rb +7 -3
  131. data/spaceship/lib/spaceship/tunes/iap_families.rb +12 -1
  132. data/spaceship/lib/spaceship/tunes/iap_family_details.rb +26 -17
  133. data/spaceship/lib/spaceship/tunes/iap_status.rb +5 -1
  134. data/spaceship/lib/spaceship/tunes/tunes_client.rb +2 -2
  135. data/supply/lib/supply/client.rb +1 -1
  136. metadata +63 -18
@@ -13,9 +13,16 @@ module Frameit
13
13
  @offsets_cache = JSON.parse(File.read(offsets_json_path))
14
14
  end
15
15
 
16
- offset_value = @offsets_cache["portrait"][screenshot.device_name]
16
+ offset_value = @offsets_cache["portrait"][sanitize_device_name(screenshot.device_name)]
17
17
  UI.error("Tried looking for offset information for 'portrait', #{screenshot.device_name} in '#{offsets_json_path}'") unless offset_value
18
18
  return offset_value
19
19
  end
20
+
21
+ def self.sanitize_device_name(basename)
22
+ # this should be the same as frames_generator's sanitize_device_name (except stripping colors):
23
+ basename = basename.gsub("Apple", "")
24
+ basename = basename.gsub("-", " ")
25
+ basename.strip.to_s
26
+ end
20
27
  end
21
28
  end
@@ -1,6 +1,8 @@
1
1
  require 'fastlane_core/configuration/config_item'
2
2
 
3
3
  require_relative 'module'
4
+ require_relative 'config_parser'
5
+ require_relative 'device_types'
4
6
 
5
7
  module Frameit
6
8
  class Options
@@ -8,74 +10,99 @@ module Frameit
8
10
  @options ||= [
9
11
 
10
12
  FastlaneCore::ConfigItem.new(key: :white,
11
- env_name: "FRAMEIT_WHITE_FRAME",
12
- description: "Use white device frames",
13
- type: Boolean,
14
- optional: true),
13
+ env_name: "FRAMEIT_WHITE_FRAME",
14
+ description: "Use white device frames",
15
+ type: Boolean,
16
+ optional: true),
15
17
  FastlaneCore::ConfigItem.new(key: :silver,
16
- env_name: "FRAMEIT_SILVER_FRAME",
17
- description: "Use white device frames. Alias for :white",
18
- type: Boolean,
19
- optional: true),
18
+ env_name: "FRAMEIT_SILVER_FRAME",
19
+ description: "Use white device frames. Alias for :white",
20
+ type: Boolean,
21
+ optional: true),
20
22
  FastlaneCore::ConfigItem.new(key: :rose_gold,
21
- env_name: "FRAMEIT_ROSE_GOLD_FRAME",
22
- description: "Use rose gold device frames. Alias for :rose_gold",
23
- type: Boolean,
24
- optional: true),
23
+ env_name: "FRAMEIT_ROSE_GOLD_FRAME",
24
+ description: "Use rose gold device frames. Alias for :rose_gold",
25
+ type: Boolean,
26
+ optional: true),
25
27
  FastlaneCore::ConfigItem.new(key: :gold,
26
- env_name: "FRAMEIT_GOLD_FRAME",
27
- description: "Use gold device frames. Alias for :gold",
28
- type: Boolean,
29
- optional: true),
28
+ env_name: "FRAMEIT_GOLD_FRAME",
29
+ description: "Use gold device frames. Alias for :gold",
30
+ type: Boolean,
31
+ optional: true),
30
32
  FastlaneCore::ConfigItem.new(key: :force_device_type,
31
- env_name: "FRAMEIT_FORCE_DEVICE_TYPE",
32
- description: "Forces a given device type, useful for Mac screenshots, as their sizes vary",
33
- optional: true,
34
- verify_block: proc do |value|
35
- available = ['iPhone_6_Plus', 'iPhone_5s', 'iPhone_4', 'iPad_mini', 'Mac']
36
- unless available.include?(value)
37
- UI.user_error!("Invalid device type '#{value}'. Available values: #{available}")
38
- end
39
- end),
33
+ env_name: "FRAMEIT_FORCE_DEVICE_TYPE",
34
+ description: "Forces a given device type, useful for Mac screenshots, as their sizes vary",
35
+ optional: true,
36
+ verify_block: proc do |value|
37
+ UI.user_error!("Invalid device type '#{value}'. Available values: " + Devices.all_device_names_without_apple.join(', ')) unless ConfigParser.supported_device?(value)
38
+ end),
40
39
  FastlaneCore::ConfigItem.new(key: :use_legacy_iphone5s,
41
- env_name: "FRAMEIT_USE_LEGACY_IPHONE_5_S",
42
- description: "Use iPhone 5s instead of iPhone SE frames",
40
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_5_S",
41
+ description: "Use iPhone 5s instead of iPhone SE frames",
42
+ default_value: false,
43
+ type: Boolean),
44
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphone6s,
45
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_6_S",
46
+ description: "Use iPhone 6s frames instead of iPhone 7 frames",
47
+ default_value: false,
48
+ type: Boolean),
49
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphone7,
50
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_7",
51
+ description: "Use iPhone 7 frames instead of iPhone 8 frames",
52
+ default_value: false,
53
+ type: Boolean),
54
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonex,
55
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_X",
56
+ description: "Use iPhone X instead of iPhone XS frames",
57
+ default_value: false,
58
+ type: Boolean),
59
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexr,
60
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_XR",
61
+ description: "Use iPhone XR instead of iPhone 11 frames",
43
62
  default_value: false,
44
63
  type: Boolean),
45
- FastlaneCore::ConfigItem.new(key: :use_legacy_iphone6s,
46
- env_name: "FRAMEIT_USE_LEGACY_IPHONE_6_S",
47
- description: "Use iPhone 6s frames instead of iPhone 7 frames",
64
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexs,
65
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_XS",
66
+ description: "Use iPhone XS instead of iPhone 11 Pro frames",
48
67
  default_value: false,
49
68
  type: Boolean),
50
- FastlaneCore::ConfigItem.new(key: :use_legacy_iphonex,
51
- env_name: "FRAMEIT_USE_LEGACY_IPHONE_X",
52
- description: "Use iPhone X instead of iPhone XS frames",
69
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexsmax,
70
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_XS_MAX",
71
+ description: "Use iPhone XS Max instead of iPhone 11 Pro Max frames",
53
72
  default_value: false,
54
73
  type: Boolean),
55
74
  FastlaneCore::ConfigItem.new(key: :force_orientation_block,
56
- type: :string_callback,
57
- description: "[Advanced] A block to customize your screenshots' device orientation",
58
- display_in_shell: false,
59
- optional: true,
60
- default_value: proc do |filename|
61
- f = filename.downcase
62
- if f.end_with?("force_landscapeleft")
63
- :landscape_left
64
- elsif f.end_with?("force_landscaperight")
65
- :landscape_right
66
- end
67
- end,
68
- default_value_dynamic: true),
75
+ type: :string_callback,
76
+ description: "[Advanced] A block to customize your screenshots' device orientation",
77
+ display_in_shell: false,
78
+ optional: true,
79
+ default_value: proc do |filename|
80
+ f = filename.downcase
81
+ if f.end_with?("force_landscapeleft")
82
+ :landscape_left
83
+ elsif f.end_with?("force_landscaperight")
84
+ :landscape_right
85
+ end
86
+ end,
87
+ default_value_dynamic: true),
69
88
  FastlaneCore::ConfigItem.new(key: :debug_mode,
70
- env_name: "FRAMEIT_DEBUG_MODE",
71
- description: "Output debug information in framed screenshots",
72
- default_value: false,
73
- type: Boolean),
89
+ env_name: "FRAMEIT_DEBUG_MODE",
90
+ description: "Output debug information in framed screenshots",
91
+ default_value: false,
92
+ type: Boolean),
74
93
  FastlaneCore::ConfigItem.new(key: :resume,
75
- env_name: "FRAMEIT_RESUME",
76
- description: "Resume frameit instead of reprocessing all screenshots",
77
- default_value: false,
78
- type: Boolean)
94
+ env_name: "FRAMEIT_RESUME",
95
+ description: "Resume frameit instead of reprocessing all screenshots",
96
+ default_value: false,
97
+ type: Boolean),
98
+ FastlaneCore::ConfigItem.new(key: :use_platform,
99
+ env_name: "FRAMEIT_USE_PLATFORM",
100
+ description: "Choose a platform, the valid options are IOS, ANDROID and ANY (IOS is default to ensure backward compatibility)",
101
+ optional: true,
102
+ default_value: Platform::IOS,
103
+ verify_block: proc do |value|
104
+ UI.user_error!("Invalid platform type '#{value}'. Available values are " + Platform.all_platforms.join(', ') + ".") unless ConfigParser.supported_platform?(value)
105
+ end)
79
106
  ]
80
107
  end
81
108
  end
@@ -14,9 +14,8 @@ module Frameit
14
14
  end
15
15
  end
16
16
 
17
- def run(path, color = nil)
17
+ def run(path, color = nil, platform = nil)
18
18
  unless color
19
- color = Frameit::Color::BLACK
20
19
  color = Frameit::Color::SILVER if Frameit.config[:white] || Frameit.config[:silver]
21
20
  color = Frameit::Color::GOLD if Frameit.config[:gold]
22
21
  color = Frameit::Color::ROSE_GOLD if Frameit.config[:rose_gold]
@@ -29,11 +28,12 @@ module Frameit
29
28
  next if skip_path?(full_path)
30
29
 
31
30
  begin
32
- screenshot = Screenshot.new(full_path, color)
31
+ config = create_config(full_path)
32
+ screenshot = Screenshot.new(full_path, color, config, platform)
33
33
 
34
34
  next if skip_up_to_date?(screenshot)
35
35
 
36
- editor = editor(screenshot)
36
+ editor = editor(screenshot, config)
37
37
 
38
38
  if editor.should_skip?
39
39
  UI.message("Skipping framing of screenshot #{screenshot.path}. No title provided in your Framefile.json or title.strings.")
@@ -71,12 +71,22 @@ module Frameit
71
71
  false
72
72
  end
73
73
 
74
- def editor(screenshot)
74
+ def editor(screenshot, config)
75
75
  if screenshot.mac?
76
- return MacEditor.new(screenshot)
76
+ return MacEditor.new(screenshot, config)
77
77
  else
78
- return Editor.new(screenshot, Frameit.config[:debug_mode])
78
+ return Editor.new(screenshot, config, Frameit.config[:debug_mode])
79
79
  end
80
80
  end
81
+
82
+ # Loads the config (colors, background, texts, etc.)
83
+ # Don't use this method to access the actual text and use `fetch_texts` instead
84
+ def create_config(screenshot_path)
85
+ config_path = File.join(File.expand_path("..", screenshot_path), "Framefile.json")
86
+ config_path = File.join(File.expand_path("../..", screenshot_path), "Framefile.json") unless File.exist?(config_path)
87
+ file = ConfigParser.new.load(config_path)
88
+ return {} unless file # no config file at all
89
+ file.fetch_value(screenshot_path)
90
+ end
81
91
  end
82
92
  end
@@ -1,87 +1,75 @@
1
- require 'deliver/app_screenshot'
2
-
3
1
  require_relative 'editor'
4
2
  require_relative 'mac_editor'
5
3
  require_relative 'device_types'
6
4
  require_relative 'module'
5
+ require_relative 'device'
7
6
 
8
7
  module Frameit
9
8
  # Represents one screenshot
10
9
  class Screenshot
11
10
  attr_accessor :path # path to the screenshot
12
11
  attr_accessor :size # size in px array of 2 elements: height and width
13
- attr_accessor :screen_size # deliver screen size type, is unique per device type, used in device_name
12
+ attr_accessor :device # device detected according to resolution, priority and settings
14
13
  attr_accessor :color # the color to use for the frame (from Frameit::Color)
15
14
 
16
15
  # path: Path to screenshot
17
16
  # color: Color to use for the frame
18
- def initialize(path, color)
17
+ def initialize(path, color, config, platform_command)
19
18
  UI.user_error!("Couldn't find file at path '#{path}'") unless File.exist?(path)
20
19
  @color = color
21
20
  @path = path
22
21
  @size = FastImage.size(path)
23
22
 
24
- @screen_size = ENV["FRAMEIT_FORCE_DEVICE_TYPE"] || Deliver::AppScreenshot.calculate_screen_size(path)
23
+ # There are three ways how we can get settings to Frameit:
24
+ # - options.rb
25
+ # - gets parameters via CLI (e. g. fastlane run frameit use_platform:"android") or fastfile (Fastlane's global
26
+ # settings for a given project)
27
+ # - see Parameters in the doc
28
+ # - contains default values and validates values
29
+ # - accessed via Frameit.config[:key]
30
+ # - lowest priority
31
+ # - commands_generator.rb
32
+ # - commands entered directly to CLI (e. g. fastlane frameit android)
33
+ # - they are passed via constructors to other classes
34
+ # - higher priority than options.rb (user may enter a command to override fastfile's global setting)
35
+ # - config_parser.rb
36
+ # - gets key / values from Framefile.json
37
+ # - see Advanced usage in the doc
38
+ # - both default and specific values can be entered in the file (filtered by file name)
39
+ # - accessed via ConfigParser.fetch_value(screenshot.path)[key] (the ConfigParser's instance is passed
40
+ # to Screenshot's constructor as config, i.e. we call config[key])
41
+ # - should have the highest priority, because user might set a specific value for a specific screenshot which
42
+ # should override CLI parameters and fastfile global setting
43
+ platform = config['use_platform'] || platform_command || Frameit.config[:use_platform]
44
+ @device = Device.find_device_by_id_or_name(config['force_device_type'] || Frameit.config[:force_device_type]) || Device.detect_device(path, platform)
25
45
  end
26
46
 
27
47
  # Device name for a given screen size. Used to use the correct template
28
48
  def device_name
29
- # rubocop:disable Require/MissingRequireStatement
30
- sizes = Deliver::AppScreenshot::ScreenSize
31
- case @screen_size
32
- when sizes::IOS_65
33
- return 'iPhone XS Max'
34
- when sizes::IOS_61
35
- return 'iPhone XR'
36
- when sizes::IOS_58
37
- return Frameit.config[:use_legacy_iphonex] ? 'iPhone X' : 'iPhone XS'
38
- when sizes::IOS_55
39
- return Frameit.config[:use_legacy_iphone6s] ? 'iPhone 6s Plus' : 'iPhone 7 Plus'
40
- when sizes::IOS_47
41
- return Frameit.config[:use_legacy_iphone6s] ? 'iPhone 6s' : 'iPhone 7'
42
- when sizes::IOS_40
43
- return Frameit.config[:use_legacy_iphone5s] ? 'iPhone 5s' : 'iPhone SE'
44
- when sizes::IOS_35
45
- return 'iPhone 4'
46
- when sizes::IOS_IPAD
47
- return 'iPad Air 2'
48
- when sizes::IOS_IPAD_10_5
49
- return 'iPad Pro (10.5-inch)'
50
- when sizes::IOS_IPAD_11
51
- return 'iPad Pro (11-inch)'
52
- when sizes::IOS_IPAD_PRO
53
- return 'iPad Pro'
54
- when sizes::IOS_IPAD_PRO_12_9
55
- return 'iPad Pro (12.9-inch) (3rd generation)'
56
- when sizes::MAC
57
- return 'MacBook'
58
- else
59
- UI.error("Unknown device type for size #{@screen_size} for path '#{path}'")
60
- end
49
+ @device.formatted_name
61
50
  # rubocop:enable Require/MissingRequireStatement
62
51
  end
63
52
 
64
- def color
65
- if !Frameit.config[:use_legacy_iphone6s] && @color == Frameit::Color::BLACK
66
- if @screen_size == Deliver::AppScreenshot::ScreenSize::IOS_55 || @screen_size == Deliver::AppScreenshot::ScreenSize::IOS_47
67
- return "Matte Black" # RIP space gray
68
- end
69
- end
70
- return @color
53
+ def default_color
54
+ @device.default_color
55
+ end
56
+
57
+ def deliver_screen_id
58
+ @device.deliver_screen_id
71
59
  end
72
60
 
73
61
  # Is the device a 3x device? (e.g. iPhone 6 Plus, iPhone X)
74
62
  def triple_density?
75
- (screen_size == Deliver::AppScreenshot::ScreenSize::IOS_55 || screen_size == Deliver::AppScreenshot::ScreenSize::IOS_58 || screen_size == Deliver::AppScreenshot::ScreenSize::IOS_65)
63
+ !device.density_ppi.nil? && device.density_ppi > 400
76
64
  end
77
65
 
78
66
  # Super old devices (iPhone 4)
79
67
  def mini?
80
- (screen_size == Deliver::AppScreenshot::ScreenSize::IOS_35)
68
+ !device.density_ppi.nil? && device.density_ppi < 300
81
69
  end
82
70
 
83
71
  def mac?
84
- return device_name == 'MacBook'
72
+ device_name == 'MacBook'
85
73
  end
86
74
 
87
75
  # The name of the orientation of a screenshot. Used to find the correct template
@@ -1,5 +1,4 @@
1
1
  require 'deliver/app_screenshot'
2
-
3
2
  require_relative 'module'
4
3
  require_relative 'device_types'
5
4
  require_relative 'frame_downloader'
@@ -11,32 +10,36 @@ module Frameit
11
10
  def self.get_template(screenshot)
12
11
  return nil if screenshot.mac?
13
12
 
14
- filename = "Apple #{screenshot.device_name} #{screenshot.color}"
15
-
13
+ filename = create_file_name(screenshot.device_name, screenshot.color.nil? ? screenshot.default_color : screenshot.color)
16
14
  templates = Dir["#{FrameDownloader.templates_path}/#{filename}.{png,jpg}"] # ~/.frameit folder
17
15
 
18
16
  UI.verbose("Looking for #{filename} and found #{templates.count} template(s)")
19
17
 
18
+ return filename if Helper.test?
19
+ if templates.count == 0 && !screenshot.color.nil? && screenshot.color != screenshot.default_color
20
+ filename = create_file_name(screenshot.device_name, screenshot.default_color)
21
+ UI.important("Unfortunately device type '#{screenshot.device_name}' is not available in #{screenshot.color}, falling back to " + (screenshot.default_color.nil? ? "default" : screenshot.default_color) + "...")
22
+ templates = Dir["#{FrameDownloader.templates_path}/#{filename}.{png,jpg}"] # ~/.frameit folder
23
+ UI.verbose("Looking for #{filename} and found #{templates.count} template(s)")
24
+ end
25
+
20
26
  if templates.count == 0
21
- if screenshot.screen_size == Deliver::AppScreenshot::ScreenSize::IOS_35
27
+ if screenshot.deliver_screen_id == Deliver::AppScreenshot::ScreenSize::IOS_35
22
28
  UI.important("Unfortunately 3.5\" device frames were discontinued. Skipping screen '#{screenshot.path}'")
23
29
  UI.error("Looked for: '#{filename}.png'")
24
- elsif screenshot.color == Frameit::Color::ROSE_GOLD || screenshot.color == Frameit::Color::GOLD
25
- # Unfortunately not every device type is available in rose gold or gold
26
- # This is why we can't have nice things #yatusabes
27
- # fallback to a white iPhone, which looks similar
28
- UI.important("Unfortunately device type '#{screenshot.device_name}' is not available in #{screenshot.color}, falling back to silver...")
29
- screenshot.color = Frameit::Color::SILVER
30
- return self.get_template(screenshot)
31
30
  else
32
31
  UI.error("Couldn't find template for screenshot type '#{filename}'")
33
32
  UI.error("Please run `fastlane frameit download_frames` to download the latest frames")
34
33
  end
35
- return filename if Helper.test?
36
34
  return nil
37
35
  else
38
36
  return templates.first.tr(" ", "\ ")
39
37
  end
40
38
  end
39
+
40
+ def self.create_file_name(device_name, color)
41
+ return "#{device_name} #{color}" unless color.nil?
42
+ return device_name
43
+ end
41
44
  end
42
45
  end
@@ -88,6 +88,13 @@ module Gym
88
88
  when "tvOS"
89
89
  destination_sdkroot = ["appletvos"]
90
90
  end
91
+
92
+ # Catalyst projects will always have an "iphoneos" sdkroot
93
+ # Need to force a same platform when trying to build as macos
94
+ if Gym.building_mac_catalyst_for_mac?
95
+ return true
96
+ end
97
+
91
98
  return destination_sdkroot.include?(sdkroot)
92
99
  end
93
100
 
@@ -134,10 +141,31 @@ module Gym
134
141
  next unless same_platform?(sdkroot)
135
142
  next unless specified_configuration == build_configuration.name
136
143
 
137
- bundle_identifier = build_configuration.resolve_build_setting("PRODUCT_BUNDLE_IDENTIFIER", target)
144
+ # Catalyst apps will have some build settings that will have a configuration
145
+ # that is specfic for macos so going to do our best to capture those
146
+ #
147
+ # There are other platform filters besides "[sdk=macosx*]" that we could use but
148
+ # this is the default that Xcode will use so this will also be our default
149
+ sdk_specifier = Gym.building_mac_catalyst_for_mac? ? "[sdk=macosx*]" : ""
150
+
151
+ # Look for sdk specific bundle identifier (if set) and fallback to general configuration if none
152
+ bundle_identifier = build_configuration.resolve_build_setting("PRODUCT_BUNDLE_IDENTIFIER#{sdk_specifier}", target)
153
+ bundle_identifier ||= build_configuration.resolve_build_setting("PRODUCT_BUNDLE_IDENTIFIER", target)
138
154
  next unless bundle_identifier
139
- provisioning_profile_specifier = build_configuration.resolve_build_setting("PROVISIONING_PROFILE_SPECIFIER", target)
140
- provisioning_profile_uuid = build_configuration.resolve_build_setting("PROVISIONING_PROFILE", target)
155
+
156
+ # Xcode prefixes "maccatalyst." if building a Catalyst app for mac and
157
+ # if DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER is set to YES
158
+ if Gym.building_mac_catalyst_for_mac? && build_configuration.resolve_build_setting("DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER", target) == "YES"
159
+ bundle_identifier = "maccatalyst.#{bundle_identifier}"
160
+ end
161
+
162
+ # Look for sdk specific provisioning profile specifier (if set) and fallback to general configuration if none
163
+ provisioning_profile_specifier = build_configuration.resolve_build_setting("PROVISIONING_PROFILE_SPECIFIER#{sdk_specifier}", target)
164
+ provisioning_profile_specifier ||= build_configuration.resolve_build_setting("PROVISIONING_PROFILE_SPECIFIER", target)
165
+
166
+ # Look for sdk specific provisioning profile uuid (if set) and fallback to general configuration if none
167
+ provisioning_profile_uuid = build_configuration.resolve_build_setting("PROVISIONING_PROFILE#{sdk_specifier}", target)
168
+ provisioning_profile_uuid ||= build_configuration.resolve_build_setting("PROVISIONING_PROFILE", target)
141
169
 
142
170
  has_profile_specifier = provisioning_profile_specifier.to_s.length > 0
143
171
  has_profile_uuid = provisioning_profile_uuid.to_s.length > 0
@@ -177,5 +205,6 @@ module Gym
177
205
 
178
206
  return provisioning_profile_mapping
179
207
  end
208
+ # rubocop:enable Metrics/PerceivedComplexity
180
209
  end
181
210
  end