Skip to content

Commit

Permalink
Merge pull request #3 from bielikb/release/1.1.0
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
bielikb authored Sep 21, 2020
2 parents 23befa7 + 6cb7eac commit 8a7ac99
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 20 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ create_xcframework(
workspace: 'path/to/your.xcworkspace',
scheme: 'framework scheme',
product_name: 'Sample', # optional if scheme doesnt match the name of your framework
include_bitcode: true,
destinations: ['iOS', 'maccatalyst'], #
destinations: ['iOS', 'maccatalyst'],
xcframework_output_directory: 'path/to/your/output dir'
)
```

Run
Run
```bash
$ fastlane actions create_xcframework
```
Expand All @@ -48,7 +47,6 @@ to learn more about the plugin.
* carPlayOS
* macOS


## Output

#### Files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def self.run(params)
XcarchiveAction.run(params)
end

create_xcframework
create_xcframework(params)

copy_dSYMs(params)

Expand All @@ -52,17 +52,41 @@ def self.clean
@xchelper.xcarchive_frameworks_path.each { |framework| FileUtils.rm_rf(framework.split('/').first) }
end

def self.create_xcframework
def self.create_xcframework(params)
xcframework = @xchelper.xcframework_path
begin
FileUtils.rm_rf(xcframework) if File.exist?(xcframework)
framework_links = @xchelper.xcarchive_frameworks_path.map { |path| "-framework #{path}" }.join(' ')
Actions.sh("set -o pipefail && xcodebuild -create-xcframework #{framework_links} -output #{xcframework}")
framework_links = params[:destinations].each_with_index.map do |_, index|
"-framework #{@xchelper.xcarchive_framework_path(index)} #{debug_symbols(index: index, params: params)}"
end

Actions.sh("set -o pipefail && xcodebuild -create-xcframework #{framework_links.join(' ')} -output #{xcframework}")
rescue => err
UI.user_error!(err)
end
end

def self.debug_symbols(index:, params:)
return "" unless Helper.xcode_at_least?('12.0.0')

debug_symbols = []

# Include dSYMs in xcframework
if params[:include_dSYMs] != false
debug_symbols << "-debug-symbols #{@xchelper.xcarchive_dSYMs_path(index)}/#{@xchelper.framework}.dSYM"
end

# Include BCSymbols in xcframework
if params[:include_BCSymbolMaps] != false && params[:include_bitcode] != false
bc_symbols_dir = @xchelper.xcarchive_BCSymbolMaps_path(index)
if Dir.exist?(bc_symbols_dir)
debug_symbols << Dir.children(bc_symbols_dir).map { |path| "-debug-symbols #{File.expand_path("#{bc_symbols_dir}/#{path}")}" }.join(' ')
end
end

debug_symbols.join(' ')
end

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

def self.copy_BCSymbolMaps(params)
return unless params[:include_bitcode]
return if params[:include_bitcode] == false

symbols_output_dir = @xchelper.xcframework_BCSymbolMaps_path
FileUtils.mkdir_p(symbols_output_dir)
Expand Down Expand Up @@ -109,7 +133,7 @@ def self.update_xcargs(params)
end
xcargs = ['SKIP_INSTALL=NO', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES']

if params[:include_bitcode]
if params[:include_bitcode] != false
params[:xcargs].gsub!(/ENABLE_BITCODE(=|\s+)(YES|NO)/, '') if params[:xcargs]
xcargs << ['OTHER_CFLAGS="-fembed-bitcode"', 'BITCODE_GENERATION_MODE="bitcode"', 'ENABLE_BITCODE=YES']
end
Expand Down Expand Up @@ -153,7 +177,6 @@ def self.example_code
create_xcframework(
workspace: 'path/to/your.xcworkspace',
scheme: 'framework scheme',
include_bitcode: true,
destinations: ['iOS'],
xcframework_output_directory: 'output_directory'
)
Expand All @@ -173,7 +196,7 @@ def self.authors
end

def self.details
"Create xcframework plugin generates xcframework for specified destinations. The output of this action consists of the xcframework itself, dSYM and BCSymbolMaps, if bitcode is enabled."
"Create xcframework plugin generates xcframework for specified destinations. The output of this action consists of the xcframework itself, which contains dSYM and BCSymbolMaps, if bitcode is enabled."
end

def self.available_options
Expand All @@ -185,10 +208,10 @@ def self.available_options
),
FastlaneCore::ConfigItem.new(
key: :include_bitcode,
description: "Should the xcframework include bitcode?",
description: "Should the project be built with bitcode enabled?",
optional: true,
is_string: false,
default_value: false
default_value: true
),
FastlaneCore::ConfigItem.new(
key: :destinations,
Expand All @@ -202,6 +225,18 @@ def self.available_options
description: "The directory in which the xcframework should be stored in",
optional: true
),
FastlaneCore::ConfigItem.new(
key: :include_dSYMs,
description: "Includes dSYM files in the xcframework",
optional: true,
default_value: true
),
FastlaneCore::ConfigItem.new(
key: :include_BCSymbolMaps,
description: "Includes BCSymbolMap files in the xcframework",
optional: true,
default_value: true
),
FastlaneCore::ConfigItem.new(
key: :product_name,
description: "The name of your module. Optional if equals to :scheme. Equivalent to CFBundleName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ def xcarchive_frameworks_path
end

def xcarchive_dSYMs_path(framework_index)
"#{xcarchive_path(framework_index)}/dSYMS"
File.expand_path("#{xcarchive_path(framework_index)}/dSYMS")
end

def xcframework_dSYMs_path
"#{output_directory}/#{product_name}.dSYMs"
File.expand_path("#{output_directory}/#{product_name}.dSYMs")
end

def xcarchive_BCSymbolMaps_path(framework_index)
"#{xcarchive_path(framework_index)}/BCSymbolMaps"
File.expand_path("#{xcarchive_path(framework_index)}/BCSymbolMaps")
end

def xcframework_BCSymbolMaps_path
"#{output_directory}/#{product_name}.BCSymbolMaps"
File.expand_path("#{output_directory}/#{product_name}.BCSymbolMaps")
end

def xcframework_path
"#{output_directory}/#{xcframework}"
File.expand_path("#{output_directory}/#{xcframework}")
end

def output_directory
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/create_xcframework/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module CreateXcframework
VERSION = "1.0.0"
VERSION = "1.1.0"
end
end

0 comments on commit 8a7ac99

Please sign in to comment.