Skip to content

Commit 93ab56d

Browse files
authored
Properly treating parameters within the action (#23)
1 parent d31a96b commit 93ab56d

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

fastlane-plugin-create_xcframework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
1717
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1818
spec.require_paths = ['lib']
1919

20-
spec.required_ruby_version = '>= 2.4'
20+
spec.required_ruby_version = '>= 2.6'
2121
spec.add_development_dependency('bundler')
2222
spec.add_development_dependency('fasterer', '0.9.0')
2323
spec.add_development_dependency('fastlane', '>= 2.182.0')

lib/fastlane/plugin/create_xcframework/actions/create_xcframework_action.rb

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ def self.run(params)
2020
@xchelper = Helper::CreateXcframeworkHelper.new(params)
2121

2222
params[:destinations].each_with_index do |destination, framework_index|
23-
params[:destination] = destination
24-
params[:archive_path] = @xchelper.xcarchive_path_for_destination(framework_index)
25-
XcarchiveAction.run(params)
23+
options = params.values
24+
options[:destination] = destination
25+
options[:archive_path] = @xchelper.xcarchive_path_for_destination(framework_index)
26+
XcarchiveAction.run(options)
2627
end
2728

2829
create_xcframework(params)
@@ -94,7 +95,7 @@ def self.debug_symbols(index:, params:)
9495
end
9596

9697
def self.copy_dSYMs(params)
97-
return if params[:include_dSYMs] == false
98+
return if params[:include_debug_symbols] == false
9899

99100
dSYMs_output_dir = @xchelper.xcframework_dSYMs_path
100101
FileUtils.mkdir_p(dSYMs_output_dir)
@@ -111,7 +112,7 @@ def self.copy_dSYMs(params)
111112
end
112113

113114
def self.copy_BCSymbolMaps(params)
114-
return if params[:enable_bitcode] == false || params[:include_BCSymbolMaps] == false
115+
return if params[:include_debug_symbols] == false || params[:enable_bitcode] == false || params[:include_BCSymbolMaps] == false
115116

116117
symbols_output_dir = @xchelper.xcframework_BCSymbolMaps_path
117118
FileUtils.mkdir_p(symbols_output_dir)
@@ -212,7 +213,17 @@ def self.details
212213
end
213214

214215
def self.available_options
215-
XcarchiveAction.available_options + [
216+
XcarchiveAction.available_options.select{ |item| item[0] != 'scheme' }.map { |elem|
217+
FastlaneCore::ConfigItem.new(
218+
key: elem[0].to_sym,
219+
description: elem[1].delete_suffix('.'),
220+
optional: true)
221+
} + [
222+
FastlaneCore::ConfigItem.new(
223+
key: :project,
224+
description: "The Xcode project to work with",
225+
optional: true
226+
),
216227
FastlaneCore::ConfigItem.new(
217228
key: :scheme,
218229
description: "The project's scheme. Make sure it's marked as Shared",
@@ -221,15 +232,13 @@ def self.available_options
221232
FastlaneCore::ConfigItem.new(
222233
key: :enable_bitcode,
223234
description: 'Should the project be built with bitcode enabled?',
224-
optional: true,
225-
is_string: false,
226-
default_value: true
235+
type: Boolean,
236+
default_value: false
227237
),
228238
FastlaneCore::ConfigItem.new(
229239
key: :destinations,
230240
description: 'Use custom destinations for building the xcframework',
231-
optional: true,
232-
is_string: false,
241+
type: Array,
233242
default_value: ['iOS']
234243
),
235244
FastlaneCore::ConfigItem.new(
@@ -240,20 +249,20 @@ def self.available_options
240249
FastlaneCore::ConfigItem.new(
241250
key: :include_dSYMs,
242251
description: 'Includes dSYM files in the xcframework',
243-
optional: true,
252+
type: Boolean,
244253
default_value: true
245254
),
246255
FastlaneCore::ConfigItem.new(
247256
key: :include_BCSymbolMaps,
248257
description: 'Includes BCSymbolMap files in the xcframework',
249-
optional: true,
250-
default_value: true
258+
type: Boolean,
259+
default_value: false
251260
),
252261
FastlaneCore::ConfigItem.new(
253262
key: :include_debug_symbols,
254263
description: 'This feature was added in Xcode 12.0.' \
255264
'If this is set to false, the dSYMs and BCSymbolMaps wont be added to XCFramework itself',
256-
optional: true,
265+
type: Boolean,
257266
default_value: true
258267
),
259268
FastlaneCore::ConfigItem.new(
@@ -265,22 +274,22 @@ def self.available_options
265274
key: :remove_xcarchives,
266275
description: 'This option will auto-remove the xcarchive files once the plugin finishes.' \
267276
'Set this to false to preserve the xcarchives',
268-
optional: true,
269-
default_value: true
277+
type: Boolean,
278+
default_value: false
270279
),
271280
FastlaneCore::ConfigItem.new(
272281
key: :allow_internal_distribution,
273282
description: 'This option will create an xcframework with the allow-internal-distribution flag.' \
274283
'Allows the usage of @testable when importing the created xcframework in tests',
275-
optional: true,
284+
type: Boolean,
276285
default_value: false
277286
),
278287
FastlaneCore::ConfigItem.new(
279288
key: :override_xcargs,
280289
description: 'This option will override xcargs SKIP_INSTALL and BUILD_LIBRARY_FOR_DISTRIBUTION.' \
281-
'If set to true, SKIP_INSTALL will be set to NO and BUILD_LIBRARY_FOR_DISTRIBUTION will be set to YES' \
290+
'If set to true, SKIP_INSTALL will be set to NO and BUILD_LIBRARY_FOR_DISTRIBUTION will be set to YES.' \
282291
'Set this to false to preserve the passed xcargs',
283-
optional: true,
292+
type: Boolean,
284293
default_value: true
285294
)
286295
]

spec/fastlane_create_xcframework_action_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
it 'verifies available_destinations method' do
99
expected_destinations = [
10-
'iOS', 'iPadOS', 'macOS', 'tvOS', 'watchOS', 'carPlayOS', 'maccatalyst'
10+
'iOS', 'iPadOS', 'macOS', 'tvOS', 'watchOS', 'carPlayOS', 'maccatalyst', 'visionOS'
1111
]
1212
actual_destinations = described_class.available_destinations.keys
1313
expect(actual_destinations.sort).to eq(expected_destinations.sort)
@@ -133,7 +133,7 @@
133133
end
134134

135135
it 'verifies copy_dSYMs method when :include_dSYMs option is equals to false' do
136-
params = { include_dSYMs: false }
136+
params = { include_debug_symbols: false }
137137
described_class.copy_dSYMs(params)
138138
expect(FileUtils).not_to receive(:mkdir_p)
139139
end
@@ -146,7 +146,7 @@
146146
allow(FileUtils).to receive(:mkdir_p)
147147
allow(FileUtils).to receive(:cp_r)
148148

149-
params = { include_dSYMs: false }
149+
params = { include_debug_symbols: true, destinations: ['iOS'] }
150150
described_class.copy_dSYMs(params)
151151
expect(FileUtils).not_to receive(:mkdir_p)
152152
end

0 commit comments

Comments
 (0)