fastlane-plugin-create_simulator_devices 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97c45d507e589509620dd5bfc35a27ae50948ebcba6c886b056b940b3da84a4a
4
- data.tar.gz: cc4c4d2c65c49341a01f28c36df7c99713b78c493ad66272fad69570feaf2b7d
3
+ metadata.gz: 0e4f2a4d905fad425dc7b871cb55ee0ea48c0d36b8417d26d6cfa1a49fd97737
4
+ data.tar.gz: 1f123387acdf4df42f374ec7ba14d2c0aed1f30587c1c2ba8c9f362a848641fe
5
5
  SHA512:
6
- metadata.gz: bf6e1da7e6f5a89b38f0ae6a180e2a1d9cda9c5bbf7fcdb1bc1bad8e98e947acf7bff35818ec5eb435e676fe486efa5b28ffa6e6c9dd8c1cb59dea8184c1a907
7
- data.tar.gz: c0ad977064e5be87a3d0003db5de5ff10592fe40792c1c718209dd61f9df0498a7ac2eda1ed659f5529ebcfa619a04891608c3cab90072f64e43f91a01e71eba
6
+ metadata.gz: 7183aeb1d262c2b7faeadb35750ecf0f04982ef9a978b2e397ec66c5fac5a5a10b94494a525355b74711a25a26a8f7c5a1af2415c57fb6d2db2ff7776461dd16
7
+ data.tar.gz: 9404401a0f27c170011f87e3707a901f0ac3ae1294ce7ebceb1519648b94b3e6e74cd049b520d288471160852d0c1cf1bc931a05ca8413fa177624da82b60cf3
@@ -4,14 +4,14 @@ module Fastlane
4
4
  module CreateSimulatorDevices
5
5
  # Represents a required runtime.
6
6
  class RequiredDevice
7
- attr_accessor :device_type, :os_name, :required_runtime, :available_runtime, :available_device
7
+ attr_accessor :device_type, :os_name, :required_runtime, :simctl_runtime, :simctl_device
8
8
 
9
- def initialize(device_type:, os_name:, required_runtime:, available_runtime:, available_device:)
9
+ def initialize(device_type:, os_name:, required_runtime:, simctl_runtime:, simctl_device:)
10
10
  self.device_type = device_type
11
11
  self.os_name = os_name
12
12
  self.required_runtime = required_runtime
13
- self.available_runtime = available_runtime
14
- self.available_device = available_device
13
+ self.simctl_runtime = simctl_runtime
14
+ self.simctl_device = simctl_device
15
15
  end
16
16
 
17
17
  def description
@@ -46,14 +46,16 @@ module Fastlane
46
46
 
47
47
  # Return distinct matched devices strings
48
48
  matched_devices = required_devices
49
- .reject { |required_device| required_device.available_device.nil? }
49
+ .reject { |required_device| required_device.simctl_device.nil? }
50
50
 
51
51
  log_matched_devices(matched_devices: matched_devices)
52
52
 
53
- available_simulator_devices = matched_devices.map(&:available_device)
54
- Actions.lane_context[Actions::SharedValues::AVAILABLE_SIMULATOR_DEVICES] = available_simulator_devices
53
+ Actions.lane_context[Actions::SharedValues::AVAILABLE_SIMULATOR_DEVICES] = matched_devices
55
54
 
56
- matched_devices.map(&:description)
55
+ matched_devices_names = matched_devices.map(&:description)
56
+ UI.message("Available simulator devices: #{matched_devices_names.join(', ')}")
57
+
58
+ matched_devices_names
57
59
  end
58
60
 
59
61
  def log_matched_devices(matched_devices:)
@@ -63,46 +65,41 @@ module Fastlane
63
65
  matched_devices.each do |matched_device|
64
66
  device_info = ''
65
67
  if verbose
66
- device_info = shell_helper.device_info_by_udid(matched_device.available_device.udid)
68
+ device_info = shell_helper.device_info_by_udid(matched_device.simctl_device.udid)
67
69
  device_info = "\n#{device_info}"
68
70
  end
69
- UI.message(" #{matched_device.description}: #{matched_device.available_device.description}#{device_info}")
71
+ UI.message(" #{matched_device.description}: #{matched_device.simctl_device.description}#{device_info}")
70
72
  end
71
-
72
- matched_devices_names = matched_devices
73
- .map { |matched_device| matched_device.available_device.name }
74
- .join(', ')
75
- UI.message("Available simulator devices: #{matched_devices_names}")
76
73
  end
77
74
 
78
75
  def delete_unavailable_devices
79
- return unless shell_helper.available_devices_for_runtimes.values.flatten.any?(&:available?)
76
+ return unless shell_helper.simctl_devices_for_runtimes.values.flatten.any?(&:available?)
80
77
 
81
78
  shell_helper.delete_unavailable_devices
82
79
 
83
- shell_helper.available_devices_for_runtimes(force: true)
80
+ shell_helper.simctl_devices_for_runtimes(force: true)
84
81
  end
85
82
 
86
- def available_device_for_required_device(required_device)
87
- return nil if required_device.available_runtime.nil?
83
+ def simctl_device_for_required_device(required_device)
84
+ return nil if required_device.simctl_runtime.nil?
88
85
 
89
- available_devices = shell_helper.available_devices_for_runtimes[required_device.available_runtime.identifier.to_sym]
86
+ simctl_devices = shell_helper.simctl_devices_for_runtimes[required_device.simctl_runtime.identifier.to_sym]
90
87
 
91
- return [] if available_devices.nil?
88
+ return [] if simctl_devices.nil?
92
89
 
93
90
  # Find the device with the same name as the required device.
94
- devices_with_same_type = available_devices
95
- .select { |available_device| available_device.device_type_identifier == required_device.device_type.identifier }
91
+ devices_with_same_type = simctl_devices
92
+ .select { |simctl_device| simctl_device.device_type_identifier == required_device.device_type.identifier }
96
93
 
97
94
  devices_with_same_type
98
- .detect { |available_device| available_device.name == required_device.device_type.name }
95
+ .detect { |simctl_device| simctl_device.name == required_device.device_type.name }
99
96
  end
100
97
 
101
98
  def create_missing_devices(required_devices)
102
99
  find_runtime_and_device_for_required_devices(required_devices)
103
100
 
104
101
  missing_devices = required_devices
105
- .select { |required_device| required_device.available_device.nil? }
102
+ .select { |required_device| required_device.simctl_device.nil? }
106
103
 
107
104
  if missing_devices.empty?
108
105
  UI.message('All required devices are present. Skipping device creation...') if verbose
@@ -114,11 +111,11 @@ module Fastlane
114
111
  shell_helper.create_device(
115
112
  missing_device.device_type.name,
116
113
  missing_device.device_type.identifier,
117
- missing_device.available_runtime.identifier
114
+ missing_device.simctl_runtime.identifier
118
115
  )
119
116
  end
120
117
 
121
- shell_helper.available_devices_for_runtimes(force: true)
118
+ shell_helper.simctl_devices_for_runtimes(force: true)
122
119
 
123
120
  find_runtime_and_device_for_required_devices(missing_devices)
124
121
  end
@@ -126,8 +123,8 @@ module Fastlane
126
123
  def find_runtime_and_device_for_required_devices(required_devices)
127
124
  UI.message('Searching for matching available devices...')
128
125
  required_devices.each do |required_device|
129
- required_device.available_runtime = runtime_helper.available_runtime_for_required_device(required_device)
130
- required_device.available_device = available_device_for_required_device(required_device)
126
+ required_device.simctl_runtime = runtime_helper.simctl_runtime_for_required_device(required_device)
127
+ required_device.simctl_device = simctl_device_for_required_device(required_device)
131
128
  end
132
129
  end
133
130
 
@@ -141,17 +138,17 @@ module Fastlane
141
138
  }.freeze
142
139
 
143
140
  def required_device_for_device(device)
144
- available_device_types = shell_helper.available_device_types
141
+ simctl_device_types = shell_helper.simctl_device_types
145
142
 
146
143
  device_os_version = device[/ \(([\d.]*?)\)$/, 1]
147
144
  device_name = device_os_version.nil? ? device : device.delete_suffix(" (#{device_os_version})").strip
148
145
 
149
- device_type = available_device_types.detect do |available_device_type|
150
- device_name == available_device_type.name
146
+ device_type = simctl_device_types.detect do |simctl_device_type|
147
+ device_name == simctl_device_type.name
151
148
  end
152
149
 
153
150
  unless device_type
154
- UI.important("Device type not found for device #{device}. Available device types: #{available_device_types.map(&:name).join(', ')}.")
151
+ UI.important("Device type not found for device #{device}. Available device types: #{simctl_device_types.map(&:name).join(', ')}.")
155
152
  return nil
156
153
  end
157
154
 
@@ -170,8 +167,8 @@ module Fastlane
170
167
  device_type:,
171
168
  os_name:,
172
169
  required_runtime: nil,
173
- available_runtime: nil,
174
- available_device: nil
170
+ simctl_runtime: nil,
171
+ simctl_device: nil
175
172
  )
176
173
 
177
174
  required_device.required_runtime = runtime_helper.required_runtime_for_device(required_device, runtime_version)
@@ -35,8 +35,8 @@ module Fastlane
35
35
  shell_helper.delete_runtime(runtime.identifier)
36
36
  end
37
37
 
38
- shell_helper.available_runtimes(force: true)
39
- shell_helper.available_devices_for_runtimes(force: true)
38
+ shell_helper.simctl_runtimes(force: true)
39
+ shell_helper.simctl_devices_for_runtimes(force: true)
40
40
  end
41
41
 
42
42
  def install_missing_runtimes(required_devices)
@@ -53,10 +53,10 @@ module Fastlane
53
53
  download_and_install_missing_runtime(missing_runtime)
54
54
  end
55
55
 
56
- # Update available_runtimes after installing the runtimes.
56
+ # Update simctl_runtimes after installing the runtimes.
57
57
  shell_helper.installed_runtimes_with_state
58
- shell_helper.available_runtimes(force: true)
59
- shell_helper.available_devices_for_runtimes(force: true)
58
+ shell_helper.simctl_runtimes(force: true)
59
+ shell_helper.simctl_devices_for_runtimes(force: true)
60
60
 
61
61
  # Check if missing runtimes are available after installing
62
62
  missing_runtimes = missing_runtimes(missing_runtimes)
@@ -71,21 +71,21 @@ module Fastlane
71
71
  def missing_runtimes(needed_runtimes)
72
72
  needed_runtimes.select do |needed_runtime|
73
73
  # Check if available runtimes contain the needed runtime.
74
- available_runtime_matching_needed_runtime?(needed_runtime).nil?
74
+ simctl_runtime_matching_needed_runtime?(needed_runtime).nil?
75
75
  end
76
76
  end
77
77
 
78
- def available_runtime_matching_needed_runtime?(needed_runtime)
79
- matching_runtimes = shell_helper.available_runtimes
80
- .select do |available_runtime|
81
- next false if needed_runtime.os_name != available_runtime.platform
78
+ def simctl_runtime_matching_needed_runtime?(needed_runtime)
79
+ matching_runtimes = shell_helper.simctl_runtimes
80
+ .select do |simctl_runtime|
81
+ next false if needed_runtime.os_name != simctl_runtime.platform
82
82
 
83
83
  # If the product version is not equal, check if the first two segments are equal.
84
- is_product_version_equal = if needed_runtime.product_version == available_runtime.version
84
+ is_product_version_equal = if needed_runtime.product_version == simctl_runtime.version
85
85
  true
86
86
  else
87
87
  lhs_segments = needed_runtime.product_version.segments
88
- rhs_segments = available_runtime.version.segments
88
+ rhs_segments = simctl_runtime.version.segments
89
89
  if rhs_segments.size == 3
90
90
  lhs_segments[0] == rhs_segments[0] && lhs_segments[1] == rhs_segments[1]
91
91
  else
@@ -95,37 +95,37 @@ module Fastlane
95
95
  next false unless is_product_version_equal
96
96
 
97
97
  # If the product version is not equal, use the available runtime version.
98
- needed_runtime.product_version = available_runtime.version
98
+ needed_runtime.product_version = simctl_runtime.version
99
99
 
100
- needed_runtime.product_build_version = [needed_runtime.product_build_version, available_runtime.build_version].compact.max
100
+ needed_runtime.product_build_version = [needed_runtime.product_build_version, simctl_runtime.build_version].compact.max
101
101
 
102
- needed_runtime.product_build_version.almost_equal?(available_runtime.build_version)
102
+ needed_runtime.product_build_version.almost_equal?(simctl_runtime.build_version)
103
103
  end
104
104
 
105
- matching_runtimes.max_by { |available_runtime| [available_runtime.version, available_runtime.build_version] }
105
+ matching_runtimes.max_by { |simctl_runtime| [simctl_runtime.version, simctl_runtime.build_version] }
106
106
  end
107
107
 
108
- def available_runtime_for_required_device(required_device)
109
- available_runtime = available_runtime_matching_needed_runtime?(required_device.required_runtime)
108
+ def simctl_runtime_for_required_device(required_device)
109
+ simctl_runtime = simctl_runtime_matching_needed_runtime?(required_device.required_runtime)
110
110
 
111
- if available_runtime.nil?
111
+ if simctl_runtime.nil?
112
112
  UI.important("Runtime #{required_device.required_runtime.description} not found. Skipping simulator creation for #{required_device.description}...")
113
113
  return nil
114
114
  end
115
115
 
116
116
  # Check if the runtime supports the device type.
117
- if available_runtime.supported_device_types
117
+ if simctl_runtime.supported_device_types
118
118
  .none? { |supported_device_type| supported_device_type.identifier == required_device.device_type.identifier }
119
- UI.important("Device type #{required_device.device_type.name} is not supported by runtime #{available_runtime.identifier}. Skipping simulator creation for #{required_device.description}...")
119
+ UI.important("Device type #{required_device.device_type.name} is not supported by runtime #{simctl_runtime.identifier}. Skipping simulator creation for #{required_device.description}...")
120
120
  return nil
121
121
  end
122
122
 
123
- if available_runtime.nil?
123
+ if simctl_runtime.nil?
124
124
  UI.important("Runtime #{required_device.required_runtime.description} not found. Skipping simulator creation for #{required_device.description}...")
125
125
  return nil
126
126
  end
127
127
 
128
- available_runtime
128
+ simctl_runtime
129
129
  end
130
130
 
131
131
  def download_and_install_missing_runtime(missing_runtime)
@@ -184,7 +184,7 @@ module Fastlane
184
184
  end
185
185
 
186
186
  def required_runtime_for_device(required_device, runtime_version)
187
- sdk = max_available_simulator_sdks[required_device.os_name]
187
+ sdk = max_xcodebuild_simulator_sdks[required_device.os_name]
188
188
 
189
189
  # If the runtime version is the same as the SDK version, use the SDK build version.
190
190
  # This will allow to use different runtimes for the same version but different Xcode beta versions.
@@ -205,10 +205,10 @@ module Fastlane
205
205
  end
206
206
 
207
207
  # Returns a hash where key is platform string and value is sdk version.
208
- def max_available_simulator_sdks
209
- return @max_available_simulator_sdks unless @max_available_simulator_sdks.nil?
208
+ def max_xcodebuild_simulator_sdks
209
+ return @max_xcodebuild_simulator_sdks unless @max_xcodebuild_simulator_sdks.nil?
210
210
 
211
- @max_available_simulator_sdks = shell_helper.available_sdks
211
+ @max_xcodebuild_simulator_sdks = shell_helper.xcodebuild_sdks
212
212
  # Only simulators
213
213
  .filter { |sdk| sdk.platform.include?('simulator') }
214
214
  # Calculate max version for each product name
@@ -218,7 +218,7 @@ module Fastlane
218
218
  sdk_versions[os_name] = sdk if stored_sdk.nil? || sdk.product_version > stored_sdk.product_version
219
219
  end
220
220
 
221
- @max_available_simulator_sdks
221
+ @max_xcodebuild_simulator_sdks
222
222
  end
223
223
  end
224
224
  end
@@ -53,17 +53,17 @@ module Fastlane
53
53
  end
54
54
  end
55
55
 
56
- def available_device_types(force: false)
57
- return @available_device_types unless force || @available_device_types.nil?
56
+ def simctl_device_types(force: false)
57
+ return @simctl_device_types unless force || @simctl_device_types.nil?
58
58
 
59
59
  UI.message('Fetching available device types...')
60
60
  json = sh(command: 'xcrun simctl list --json --no-escape-slashes devicetypes')
61
61
 
62
- @available_device_types = JSON
62
+ @simctl_device_types = JSON
63
63
  .parse(json, symbolize_names: true)[:devicetypes]
64
64
  .map { |device_type| SimCTL::DeviceType.from_hash(device_type) }
65
65
 
66
- @available_device_types
66
+ @simctl_device_types
67
67
  end
68
68
 
69
69
  def delete_device(udid)
@@ -76,31 +76,31 @@ module Fastlane
76
76
  sh(command: 'xcrun simctl delete unavailable')
77
77
  end
78
78
 
79
- def available_devices_for_runtimes(force: false)
80
- return @available_devices_for_runtimes unless force || @available_devices_for_runtimes.nil?
79
+ def simctl_devices_for_runtimes(force: false)
80
+ return @simctl_devices_for_runtimes unless force || @simctl_devices_for_runtimes.nil?
81
81
 
82
82
  UI.message('Fetching available devices...')
83
83
  json = sh(command: 'xcrun simctl list --json --no-escape-slashes devices')
84
84
 
85
- @available_devices_for_runtimes = JSON
85
+ @simctl_devices_for_runtimes = JSON
86
86
  .parse(json, symbolize_names: true)[:devices]
87
87
  .transform_values { |devices| devices.map { |device| SimCTL::Device.from_hash(device) } }
88
88
 
89
- @available_devices_for_runtimes
89
+ @simctl_devices_for_runtimes
90
90
  end
91
91
 
92
- def available_runtimes(force: false)
93
- return @available_runtimes unless force || @available_runtimes.nil?
92
+ def simctl_runtimes(force: false)
93
+ return @simctl_runtimes unless force || @simctl_runtimes.nil?
94
94
 
95
95
  UI.message('Fetching available runtimes...')
96
96
  json = sh(command: 'xcrun simctl list --json --no-escape-slashes runtimes')
97
97
 
98
- @available_runtimes = JSON
98
+ @simctl_runtimes = JSON
99
99
  .parse(json, symbolize_names: true)[:runtimes]
100
100
  .map { |runtime| SimCTL::Runtime.from_hash(runtime) }
101
101
  .select(&:available?)
102
102
 
103
- @available_runtimes
103
+ @simctl_runtimes
104
104
  end
105
105
 
106
106
  def installed_runtimes_with_state
@@ -112,17 +112,17 @@ module Fastlane
112
112
  .map { |_, runtime| SimCTL::RuntimeWithState.from_hash(runtime) }
113
113
  end
114
114
 
115
- def available_sdks(force: false)
116
- return @available_sdks unless force || @available_sdks.nil?
115
+ def xcodebuild_sdks(force: false)
116
+ return @xcodebuild_sdks unless force || @xcodebuild_sdks.nil?
117
117
 
118
118
  UI.message('Fetching available sdks...')
119
119
  json = sh(command: 'xcrun xcodebuild -showsdks -json')
120
120
 
121
- @available_sdks = JSON
121
+ @xcodebuild_sdks = JSON
122
122
  .parse(json, symbolize_names: true)
123
123
  .map { |sdk| Xcodebuild::SDK.from_hash(sdk) }
124
124
 
125
- @available_sdks
125
+ @xcodebuild_sdks
126
126
  end
127
127
 
128
128
  def create_device(name, device_type_identifier, runtime_identifier)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module CreateSimulatorDevices
5
- VERSION = '0.0.11'
5
+ VERSION = '0.0.12'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-create_simulator_devices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Budnik