fastlane-plugin-create_simulator_devices 0.0.18 → 0.0.20

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: 97e225aefb5c19c442c8b1d91dc978988ae18112c67101675410f3c4619f1890
4
- data.tar.gz: d6a331652a7dbd2eee226f7b82a7096ce1abb875bbfb0f5cc87e8a81bce94f42
3
+ metadata.gz: 90a9e367b6c4f8fdebf950f90e2c8a5132e84f70b8e29e7f1fd9f7e0d35ff844
4
+ data.tar.gz: 1798f2157c42c4c0d127205b911f5bc8b4ed11216c68385d7f22156f6a1253e9
5
5
  SHA512:
6
- metadata.gz: aeebdd926046ca88b8614e02f2f3dc6b4f24a724fe1cccdc7f2ac412ef3528ca4b113d07c5eedc35af063be5b256b36ce42267c4bfe3d3280189729a1b837625
7
- data.tar.gz: 8528b9428574f4ba9f8d31d9878d3d825bf7374095e79d8413269fc7d889aecb2f5d33561a8bb3ac0a2316f1d94e3045b0261e8af525fb5e1d1dfe23b88fb53d
6
+ metadata.gz: d9ef8d640a6385c091b2a4829bd45f8826bdf4ad142f496a2b19a5d18c4e878a4427d3e02f452a975ae2b63dc38dca89cf78ee6c34140fa56172597e145eb556
7
+ data.tar.gz: b2af15e0226b095f38b6af3c8c77be9453756c816db65980fb0abf20fcc0c0793e8b30302ceb8f848c6a4390eee09e87230565323a914fedfc7b01a8eacd6104
@@ -33,7 +33,8 @@ module Fastlane
33
33
  can_delete_duplicate_devices: params[:delete_duplicate_devices],
34
34
  device_naming_style: params[:device_naming_style].to_sym,
35
35
  remove_cached_runtimes: params[:remove_cached_runtimes],
36
- update_dyld_shared_cache: params[:update_dyld_shared_cache]
36
+ update_dyld_shared_cache: params[:update_dyld_shared_cache],
37
+ delete_unused_runtimes: params[:delete_unused_runtimes]
37
38
  )
38
39
 
39
40
  runner.run(required_devices)
@@ -120,6 +121,12 @@ module Fastlane
120
121
  description: 'Update dyld shared cache',
121
122
  type: Boolean,
122
123
  optional: true,
124
+ default_value: false),
125
+ ::FastlaneCore::ConfigItem.new(key: :delete_unused_runtimes,
126
+ env_name: 'CREATE_SIMULATOR_DEVICES_DELETE_UNUSED_RUNTIMES',
127
+ description: 'Delete unused runtimes',
128
+ type: Boolean,
129
+ optional: true,
123
130
  default_value: false)
124
131
  ]
125
132
  end
@@ -10,7 +10,6 @@ require_relative '../helpers/gather_simctl_diagnose/runner'
10
10
  module Fastlane
11
11
  module Actions
12
12
  GatherSimctlDiagnose = ::Fastlane::GatherSimctlDiagnose
13
- CreateSimulatorDevices = ::Fastlane::CreateSimulatorDevices
14
13
 
15
14
  # Gather simctl diagnose data.
16
15
  class GatherSimctlDiagnoseAction < Fastlane::Action
@@ -34,7 +33,9 @@ module Fastlane
34
33
  can_rename_devices: false,
35
34
  can_delete_duplicate_devices: false,
36
35
  device_naming_style: params[:device_naming_style].to_sym,
37
- remove_cached_runtimes: false
36
+ remove_cached_runtimes: false,
37
+ update_dyld_shared_cache: false,
38
+ delete_unused_runtimes: false
38
39
  )
39
40
 
40
41
  runner = GatherSimctlDiagnose::Runner.new(
@@ -8,14 +8,15 @@ module Fastlane
8
8
  module SimCTL
9
9
  # Represents a runtime from `xcrun simctl runtime list --json` output.
10
10
  class RuntimeWithState
11
- attr_accessor :identifier, :version, :build, :state, :deletable
11
+ attr_accessor :identifier, :version, :build, :state, :deletable, :runtime_identifier
12
12
 
13
- def initialize(identifier:, version:, build:, state:, deletable:)
13
+ def initialize(identifier:, version:, build:, state:, deletable:, runtime_identifier:) # rubocop:disable Metrics/ParameterLists
14
14
  self.identifier = identifier
15
15
  self.version = version
16
16
  self.build = build
17
17
  self.state = state
18
18
  self.deletable = deletable
19
+ self.runtime_identifier = runtime_identifier
19
20
  end
20
21
 
21
22
  def ready?
@@ -32,11 +33,12 @@ module Fastlane
32
33
 
33
34
  def self.from_hash(hash)
34
35
  new(
35
- identifier: hash[:identifier],
36
+ identifier: hash[:identifier].to_s,
36
37
  version: Gem::Version.new(hash[:version]),
37
38
  build: AppleBuildVersion.new(hash[:build]),
38
- state: hash[:state],
39
- deletable: hash[:deletable]
39
+ state: hash[:state].to_s,
40
+ deletable: hash[:deletable],
41
+ runtime_identifier: hash[:runtimeIdentifier].to_s
40
42
  )
41
43
  end
42
44
  end
@@ -12,9 +12,9 @@ module Fastlane
12
12
  class Runner
13
13
  UI = ::Fastlane::UI unless defined?(UI)
14
14
 
15
- attr_accessor :shell_helper, :verbose, :runtime_helper, :can_rename_devices, :can_delete_duplicate_devices, :device_naming_style, :remove_cached_runtimes, :update_dyld_shared_cache
15
+ attr_accessor :shell_helper, :verbose, :runtime_helper, :can_rename_devices, :can_delete_duplicate_devices, :device_naming_style, :remove_cached_runtimes, :update_dyld_shared_cache, :delete_unused_runtimes
16
16
 
17
- def initialize(runtime_helper:, shell_helper:, verbose:, can_rename_devices:, can_delete_duplicate_devices:, device_naming_style:, remove_cached_runtimes:, update_dyld_shared_cache:) # rubocop:disable Metrics/ParameterLists
17
+ def initialize(runtime_helper:, shell_helper:, verbose:, can_rename_devices:, can_delete_duplicate_devices:, device_naming_style:, remove_cached_runtimes:, update_dyld_shared_cache:, delete_unused_runtimes:) # rubocop:disable Metrics/ParameterLists
18
18
  self.shell_helper = shell_helper
19
19
  self.verbose = verbose
20
20
  self.runtime_helper = runtime_helper
@@ -23,6 +23,7 @@ module Fastlane
23
23
  self.device_naming_style = device_naming_style
24
24
  self.remove_cached_runtimes = remove_cached_runtimes
25
25
  self.update_dyld_shared_cache = update_dyld_shared_cache
26
+ self.delete_unused_runtimes = delete_unused_runtimes
26
27
  end
27
28
 
28
29
  def run(devices)
@@ -45,7 +46,7 @@ module Fastlane
45
46
  end
46
47
 
47
48
  # Install missing runtimes if needed.
48
- runtime_helper.install_missing_runtimes(required_devices, remove_cached_runtimes: remove_cached_runtimes)
49
+ runtime_helper.install_missing_runtimes(required_devices, remove_cached_runtimes: remove_cached_runtimes, delete_unused_runtimes: delete_unused_runtimes)
49
50
 
50
51
  # Create missing devices for required devices.
51
52
  create_missing_devices(required_devices)
@@ -196,6 +197,8 @@ module Fastlane
196
197
 
197
198
  UI.message('Creating missing devices')
198
199
  missing_devices.each do |missing_device|
200
+ next if missing_device.simctl_runtime.nil?
201
+
199
202
  shell_helper.create_device(
200
203
  device_name_for_required_device(missing_device),
201
204
  missing_device.device_type.identifier,
@@ -7,7 +7,7 @@ require_relative 'shell_helper'
7
7
  module Fastlane
8
8
  module CreateSimulatorDevices
9
9
  # Helper class for managing simulator runtimes.
10
- class RuntimeHelper
10
+ class RuntimeHelper # rubocop:disable Metrics/ClassLength
11
11
  UI = ::Fastlane::UI unless defined?(UI)
12
12
 
13
13
  attr_accessor :cache_dir, :shell_helper, :verbose
@@ -46,13 +46,14 @@ module Fastlane
46
46
  shell_helper.simctl_devices_for_runtimes(force: true)
47
47
  end
48
48
 
49
- def install_missing_runtimes(required_devices, remove_cached_runtimes:)
49
+ def install_missing_runtimes(required_devices, remove_cached_runtimes:, delete_unused_runtimes:)
50
50
  needed_runtimes = required_devices.filter_map(&:required_runtime).uniq
51
51
 
52
52
  missing_runtimes = missing_runtimes(needed_runtimes)
53
53
 
54
54
  if missing_runtimes.empty?
55
55
  UI.message('All required runtimes are present. Skipping runtime installation...') if verbose
56
+ delete_unused_runtimes(needed_runtimes) if delete_unused_runtimes
56
57
  return
57
58
  end
58
59
 
@@ -61,6 +62,7 @@ module Fastlane
61
62
  end
62
63
 
63
64
  # Update simctl_runtimes after installing the runtimes.
65
+ shell_helper.stop_core_simulator_services
64
66
  shell_helper.installed_runtimes_with_state
65
67
  shell_helper.simctl_runtimes(force: true)
66
68
  shell_helper.simctl_devices_for_runtimes(force: true)
@@ -73,6 +75,42 @@ module Fastlane
73
75
  .each do |missing_runtime|
74
76
  UI.important("Failed to find/download/install runtime #{missing_runtime.runtime_name}")
75
77
  end
78
+
79
+ delete_unused_runtimes(needed_runtimes) if delete_unused_runtimes
80
+ end
81
+
82
+ def delete_unused_runtimes(needed_runtimes)
83
+ UI.message('Deleting unused runtimes...')
84
+ available_simctl_runtimes = shell_helper.simctl_runtimes
85
+
86
+ needed_simctl_runtimes = needed_runtimes.map do |needed_runtime|
87
+ # Check if available runtimes contain the needed runtime.
88
+ simctl_runtime_matching_needed_runtime?(needed_runtime)
89
+ end
90
+
91
+ unused_simctl_runtimes = available_simctl_runtimes.reject do |available_simctl_runtime|
92
+ needed_simctl_runtimes.any? do |needed_simctl_runtime|
93
+ needed_simctl_runtime.identifier == available_simctl_runtime.identifier
94
+ end
95
+ end
96
+
97
+ unused_simctl_runtimes = unused_simctl_runtimes.filter_map do |unused_simctl_runtime|
98
+ shell_helper.installed_runtimes_with_state.detect do |installed_simctl_runtime|
99
+ installed_simctl_runtime.runtime_identifier == unused_simctl_runtime.identifier
100
+ end
101
+ end
102
+
103
+ return if unused_simctl_runtimes.empty?
104
+
105
+ unused_simctl_runtimes.each do |unused_simctl_runtime|
106
+ puts "Deleting unused runtime #{unused_simctl_runtime.runtime_identifier} (#{unused_simctl_runtime.identifier})..."
107
+ shell_helper.simctl_delete_runtime(identifier: unused_simctl_runtime.identifier)
108
+ end
109
+
110
+ shell_helper.stop_core_simulator_services
111
+ shell_helper.installed_runtimes_with_state
112
+ shell_helper.simctl_runtimes(force: true)
113
+ shell_helper.simctl_devices_for_runtimes(force: true)
76
114
  end
77
115
 
78
116
  def missing_runtimes(needed_runtimes)
@@ -104,6 +104,11 @@ module Fastlane
104
104
  @simctl_runtimes
105
105
  end
106
106
 
107
+ def simctl_delete_runtime(identifier:)
108
+ UI.message("Deleting runtime #{identifier}...")
109
+ sh(command: "xcrun simctl runtime delete #{identifier.shellescape}")
110
+ end
111
+
107
112
  def simctl_matched_runtimes(force: false)
108
113
  return @simctl_matched_runtimes unless force || @simctl_matched_runtimes.nil?
109
114
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module CreateSimulatorDevices
5
- VERSION = '0.0.18'
5
+ VERSION = '0.0.20'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.18
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Budnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-12 00:00:00.000000000 Z
11
+ date: 2025-12-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: developers@setapp.com