Skip to content

Commit

Permalink
Properly treating parameters within the action (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirghi authored Oct 9, 2024
1 parent d31a96b commit 93ab56d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion fastlane-plugin-create_xcframework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 2.4'
spec.required_ruby_version = '>= 2.6'
spec.add_development_dependency('bundler')
spec.add_development_dependency('fasterer', '0.9.0')
spec.add_development_dependency('fastlane', '>= 2.182.0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ def self.run(params)
@xchelper = Helper::CreateXcframeworkHelper.new(params)

params[:destinations].each_with_index do |destination, framework_index|
params[:destination] = destination
params[:archive_path] = @xchelper.xcarchive_path_for_destination(framework_index)
XcarchiveAction.run(params)
options = params.values
options[:destination] = destination
options[:archive_path] = @xchelper.xcarchive_path_for_destination(framework_index)
XcarchiveAction.run(options)
end

create_xcframework(params)
Expand Down Expand Up @@ -94,7 +95,7 @@ def self.debug_symbols(index:, params:)
end

def self.copy_dSYMs(params)
return if params[:include_dSYMs] == false
return if params[:include_debug_symbols] == false

dSYMs_output_dir = @xchelper.xcframework_dSYMs_path
FileUtils.mkdir_p(dSYMs_output_dir)
Expand All @@ -111,7 +112,7 @@ def self.copy_dSYMs(params)
end

def self.copy_BCSymbolMaps(params)
return if params[:enable_bitcode] == false || params[:include_BCSymbolMaps] == false
return if params[:include_debug_symbols] == false || params[:enable_bitcode] == false || params[:include_BCSymbolMaps] == false

symbols_output_dir = @xchelper.xcframework_BCSymbolMaps_path
FileUtils.mkdir_p(symbols_output_dir)
Expand Down Expand Up @@ -212,7 +213,17 @@ def self.details
end

def self.available_options
XcarchiveAction.available_options + [
XcarchiveAction.available_options.select{ |item| item[0] != 'scheme' }.map { |elem|
FastlaneCore::ConfigItem.new(
key: elem[0].to_sym,
description: elem[1].delete_suffix('.'),
optional: true)
} + [
FastlaneCore::ConfigItem.new(
key: :project,
description: "The Xcode project to work with",
optional: true
),
FastlaneCore::ConfigItem.new(
key: :scheme,
description: "The project's scheme. Make sure it's marked as Shared",
Expand All @@ -221,15 +232,13 @@ def self.available_options
FastlaneCore::ConfigItem.new(
key: :enable_bitcode,
description: 'Should the project be built with bitcode enabled?',
optional: true,
is_string: false,
default_value: true
type: Boolean,
default_value: false
),
FastlaneCore::ConfigItem.new(
key: :destinations,
description: 'Use custom destinations for building the xcframework',
optional: true,
is_string: false,
type: Array,
default_value: ['iOS']
),
FastlaneCore::ConfigItem.new(
Expand All @@ -240,20 +249,20 @@ def self.available_options
FastlaneCore::ConfigItem.new(
key: :include_dSYMs,
description: 'Includes dSYM files in the xcframework',
optional: true,
type: Boolean,
default_value: true
),
FastlaneCore::ConfigItem.new(
key: :include_BCSymbolMaps,
description: 'Includes BCSymbolMap files in the xcframework',
optional: true,
default_value: true
type: Boolean,
default_value: false
),
FastlaneCore::ConfigItem.new(
key: :include_debug_symbols,
description: 'This feature was added in Xcode 12.0.' \
'If this is set to false, the dSYMs and BCSymbolMaps wont be added to XCFramework itself',
optional: true,
type: Boolean,
default_value: true
),
FastlaneCore::ConfigItem.new(
Expand All @@ -265,22 +274,22 @@ def self.available_options
key: :remove_xcarchives,
description: 'This option will auto-remove the xcarchive files once the plugin finishes.' \
'Set this to false to preserve the xcarchives',
optional: true,
default_value: true
type: Boolean,
default_value: false
),
FastlaneCore::ConfigItem.new(
key: :allow_internal_distribution,
description: 'This option will create an xcframework with the allow-internal-distribution flag.' \
'Allows the usage of @testable when importing the created xcframework in tests',
optional: true,
type: Boolean,
default_value: false
),
FastlaneCore::ConfigItem.new(
key: :override_xcargs,
description: 'This option will override xcargs SKIP_INSTALL and BUILD_LIBRARY_FOR_DISTRIBUTION.' \
'If set to true, SKIP_INSTALL will be set to NO and BUILD_LIBRARY_FOR_DISTRIBUTION will be set to YES' \
'If set to true, SKIP_INSTALL will be set to NO and BUILD_LIBRARY_FOR_DISTRIBUTION will be set to YES.' \
'Set this to false to preserve the passed xcargs',
optional: true,
type: Boolean,
default_value: true
)
]
Expand Down
6 changes: 3 additions & 3 deletions spec/fastlane_create_xcframework_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

it 'verifies available_destinations method' do
expected_destinations = [
'iOS', 'iPadOS', 'macOS', 'tvOS', 'watchOS', 'carPlayOS', 'maccatalyst'
'iOS', 'iPadOS', 'macOS', 'tvOS', 'watchOS', 'carPlayOS', 'maccatalyst', 'visionOS'
]
actual_destinations = described_class.available_destinations.keys
expect(actual_destinations.sort).to eq(expected_destinations.sort)
Expand Down Expand Up @@ -133,7 +133,7 @@
end

it 'verifies copy_dSYMs method when :include_dSYMs option is equals to false' do
params = { include_dSYMs: false }
params = { include_debug_symbols: false }
described_class.copy_dSYMs(params)
expect(FileUtils).not_to receive(:mkdir_p)
end
Expand All @@ -146,7 +146,7 @@
allow(FileUtils).to receive(:mkdir_p)
allow(FileUtils).to receive(:cp_r)

params = { include_dSYMs: false }
params = { include_debug_symbols: true, destinations: ['iOS'] }
described_class.copy_dSYMs(params)
expect(FileUtils).not_to receive(:mkdir_p)
end
Expand Down

0 comments on commit 93ab56d

Please sign in to comment.