fastlane-plugin-create_xcframework 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b199e1658ad27bf2635c6d0be824149ac918fb1af0882fe0961a0526a62dcf17
4
+ data.tar.gz: '0288aba2a3501574f4c90b0b4f242f69fb53eb89fb72d97752150ea1351fe266'
5
+ SHA512:
6
+ metadata.gz: 9e1b1d76e028c043922a50b4151f8c2ef797a919e8646c7a3593db50e83048abd7188b16023ab3133e41296f3133b06d2f797ef132ad2b5df4ea3b0773ef7610
7
+ data.tar.gz: e4de2decf10795804c63b35966de57f4faa8725a7861ed473b4a145713616e3e33355344a958ba275b8e99cf8098c37306e6706df0215b34bc1cd824f9007dae
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Boris Bielik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,32 @@
1
+ # create_xcframework plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-create_xcframework)
4
+
5
+ ## About create_xcframework
6
+
7
+ Fastlane plugin that creates xcframework for given list of destinations 🚀
8
+
9
+ ## Requirements
10
+
11
+ * Xcode 11.x or greater. Download it at the [Apple Developer - Downloads](https://developer.apple.com/downloads) or the [Mac App Store](https://apps.apple.com/us/app/xcode/id497799835?mt=12).
12
+
13
+ ## Getting Started
14
+
15
+ To get started with `create_xcframework`, add it to your project by running:
16
+
17
+ ```bash
18
+ $ fastlane add_plugin create_xcframework
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ create_xcframework(
25
+ product_name: 'Sample',
26
+ scheme: 'Sample',
27
+ workspace: 'Sample.xcworkspace',
28
+ include_bitcode: true,
29
+ destinations: ['iOS', 'maccatalyst'],
30
+ xcframework_output_directory: 'Products/xcframeworks'
31
+ )
32
+ ```
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/create_xcframework/version'
2
+
3
+ module Fastlane
4
+ module CreateXcframework
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::CreateXcframework.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,222 @@
1
+ module Fastlane
2
+ module Actions
3
+ module SharedValues
4
+ XCFRAMEWORK_OUTPUT_PATH ||= :XCFRAMEWORK_OUTPUT_PATH
5
+ XCFRAMEWORK_DSYM_OUTPUT_PATH ||= :XCFRAMEWORK_DSYM_OUTPUT_PATH
6
+ XCFRAMEWORK_BCSYMBOLMAPS_OUTPUT_PATH ||= :XCFRAMEWORK_BCSYMBOLMAPS_OUTPUT_PATH
7
+ end
8
+
9
+ require 'fastlane_core/ui/ui'
10
+ require 'fastlane/actions/xcodebuild'
11
+ require_relative '../helper/create_xcframework_helper'
12
+
13
+ class CreateXcframeworkAction < Action
14
+ def self.run(params)
15
+ if Helper.xcode_at_least?('11.0.0')
16
+ verify_delicate_params(params)
17
+ params[:destinations] = update_destinations(params)
18
+ params[:xcargs] = update_xcargs(params)
19
+
20
+ @xchelper = Helper::CreateXcframeworkHelper.new(params)
21
+
22
+ params[:destinations].each_with_index do |destination, framework_index|
23
+ params[:destination] = destination
24
+ params[:archive_path] = @xchelper.xcarchive_path(framework_index)
25
+ XcarchiveAction.run(params)
26
+ end
27
+
28
+ create_xcframework
29
+
30
+ copy_dSYMs(params)
31
+
32
+ copy_BCSymbolMaps(params)
33
+
34
+ clean
35
+
36
+ provide_shared_values
37
+ else
38
+ FastlaneCore::UI.important('xcframework can be produced only using Xcode 11 and above')
39
+ end
40
+ end
41
+
42
+ def self.provide_shared_values
43
+ Actions.lane_context[SharedValues::XCFRAMEWORK_OUTPUT_PATH] = File.expand_path(@xchelper.xcframework_path)
44
+ ENV[SharedValues::XCFRAMEWORK_OUTPUT_PATH.to_s] = File.expand_path(@xchelper.xcframework_path)
45
+ Actions.lane_context[SharedValues::XCFRAMEWORK_DSYM_OUTPUT_PATH] = File.expand_path(@xchelper.xcframework_dSYMs_path)
46
+ ENV[SharedValues::XCFRAMEWORK_DSYM_OUTPUT_PATH.to_s] = File.expand_path(@xchelper.xcframework_dSYMs_path)
47
+ Actions.lane_context[SharedValues::XCFRAMEWORK_BCSYMBOLMAPS_OUTPUT_PATH] = File.expand_path(@xchelper.xcframework_BCSymbolMaps_path)
48
+ ENV[SharedValues::XCFRAMEWORK_BCSYMBOLMAPS_OUTPUT_PATH.to_s] = File.expand_path(@xchelper.xcframework_BCSymbolMaps_path)
49
+ end
50
+
51
+ def self.clean
52
+ @xchelper.xcarchive_frameworks_path.each { |framework| FileUtils.rm_rf(framework.split('/').first) }
53
+ end
54
+
55
+ def self.create_xcframework
56
+ xcframework = @xchelper.xcframework_path
57
+ begin
58
+ FileUtils.rm_rf(xcframework) if File.exist?(xcframework)
59
+ framework_links = @xchelper.xcarchive_frameworks_path.map { |path| "-framework #{path}" }.join(' ')
60
+ Actions.sh("set -o pipefail && xcodebuild -create-xcframework #{framework_links} -output #{xcframework}")
61
+ rescue => err
62
+ UI.user_error!(err)
63
+ end
64
+ end
65
+
66
+ def self.copy_dSYMs(params)
67
+ dSYMs_output_dir = @xchelper.xcframework_dSYMs_path
68
+ FileUtils.mkdir_p(dSYMs_output_dir)
69
+
70
+ params[:destinations].each_with_index do |_, framework_index|
71
+ dSYM_source = "#{@xchelper.xcarchive_dSYMs_path(framework_index)}/#{@xchelper.framework}.dSYM"
72
+ identifier = @xchelper.library_identifier(framework_index)
73
+ dSYM = "#{@xchelper.framework}.#{identifier}.dSYM"
74
+ dSYM_destination = "#{dSYMs_output_dir}/#{dSYM}"
75
+
76
+ FastlaneCore::UI.important("â–¸ Copying #{dSYM} to #{dSYMs_output_dir}")
77
+ FileUtils.cp_r(dSYM_source, dSYM_destination)
78
+ end
79
+ end
80
+
81
+ def self.copy_BCSymbolMaps(params)
82
+ return unless params[:include_bitcode]
83
+
84
+ symbols_output_dir = @xchelper.xcframework_BCSymbolMaps_path
85
+ FileUtils.mkdir_p(symbols_output_dir)
86
+
87
+ params[:destinations].each_with_index do |_, framework_index|
88
+ symbols_xcarchive_dir = @xchelper.xcarchive_BCSymbolMaps_path(framework_index)
89
+ next unless Dir.exist?(symbols_xcarchive_dir)
90
+
91
+ FileUtils.cp_r("#{symbols_xcarchive_dir}/.", symbols_output_dir)
92
+ FastlaneCore::UI.important("â–¸ Copying #{Dir.children(symbols_xcarchive_dir)} to #{symbols_output_dir}")
93
+ end
94
+ end
95
+
96
+ def self.verify_delicate_params(params)
97
+ UI.user_error!("Error: :scheme is required option") if params[:scheme].nil?
98
+ if !params[:destinations].nil? && !params[:destinations].kind_of?(Array)
99
+ UI.user_error!("Error: :destinations option should be presented as Array")
100
+ end
101
+ end
102
+
103
+ def self.update_xcargs(params)
104
+ FastlaneCore::UI.important('Overwriting SKIP_INSTALL and BUILD_LIBRARY_FOR_DISTRIBUTION options')
105
+ if params[:xcargs]
106
+ params[:xcargs].gsub!(/SKIP_INSTALL(=|\s+)(YES|NO)/, '')
107
+ params[:xcargs].gsub!(/BUILD_LIBRARY_FOR_DISTRIBUTION(=|\s+)(YES|NO)/, '')
108
+ params[:xcargs] += ' '
109
+ end
110
+ xcargs = ['SKIP_INSTALL=NO', 'BUILD_LIBRARY_FOR_DISTRIBUTION=YES']
111
+
112
+ if params[:include_bitcode]
113
+ params[:xcargs].gsub!(/ENABLE_BITCODE(=|\s+)(YES|NO)/, '') if params[:xcargs]
114
+ xcargs << ['OTHER_CFLAGS="-fembed-bitcode"', 'BITCODE_GENERATION_MODE="bitcode"', 'ENABLE_BITCODE=YES']
115
+ end
116
+
117
+ params[:xcargs].to_s + xcargs.join(' ')
118
+ end
119
+
120
+ def self.update_destinations(params)
121
+ return available_destinations.values[0] if params[:destinations].nil?
122
+
123
+ requested_destinations = params[:destinations].map do |requested_de|
124
+ available_destinations.select { |available_de, _| available_de == requested_de }.values
125
+ end
126
+ UI.user_error!("Error: available destinations: #{available_destinations.keys}") if requested_destinations.any?(&:empty?)
127
+
128
+ requested_destinations.flatten
129
+ end
130
+
131
+ def self.available_destinations
132
+ {
133
+ 'iOS' => ['generic/platform=iOS', 'generic/platform=iOS Simulator'],
134
+ 'iPadOS' => ['generic/platform=iPadOS', 'generic/platform=iPadOS Simulator'],
135
+ 'tvOS' => ['generic/platform=tvOS', 'generic/platform=tvOS Simulator'],
136
+ 'watchOS' => ['generic/platform=watchOS', 'generic/platform=watchOS Simulator'],
137
+ 'carPlayOS' => ['generic/platform=carPlayOS', 'generic/platform=carPlayOS Simulator'],
138
+ 'macOS' => ['generic/platform=macOS'],
139
+ 'maccatalyst' => ['generic/platform=macOS,variant=Mac Catalyst']
140
+ }
141
+ end
142
+
143
+ #####################################################
144
+ # Documentation #
145
+ #####################################################
146
+
147
+ def self.description
148
+ "Fastlane plugin that creates xcframework for given list of destinations."
149
+ end
150
+
151
+ def self.example_code
152
+ [
153
+ create_xcframework(
154
+ workspace: 'path/to/your.xcworkspace',
155
+ scheme: 'framework scheme',
156
+ include_bitcode: true,
157
+ destinations: ['iOS'],
158
+ xcframework_output_directory: 'output_directory'
159
+ )
160
+ ]
161
+ end
162
+
163
+ def self.output
164
+ [
165
+ ['XCFRAMEWORK_OUTPUT_PATH', 'The path to the newly generated xcframework'],
166
+ ['XCFRAMEWORK_DSYM_OUTPUT_PATH', 'The path to the folder with dSYMs'],
167
+ ['XCFRAMEWORK_BCSYMBOLMAPS_OUTPUT_PATH', 'The path to the folder with BCSymbolMaps']
168
+ ]
169
+ end
170
+
171
+ def self.authors
172
+ ["Boris Bielik", "Alexey Alter-Pesotskiy"]
173
+ end
174
+
175
+ def self.details
176
+ "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."
177
+ end
178
+
179
+ def self.available_options
180
+ XcarchiveAction.available_options + [
181
+ FastlaneCore::ConfigItem.new(
182
+ key: :scheme,
183
+ description: "The project's scheme. Make sure it's marked as Shared",
184
+ optional: false
185
+ ),
186
+ FastlaneCore::ConfigItem.new(
187
+ key: :include_bitcode,
188
+ description: "Should the xcframework include bitcode?",
189
+ optional: true,
190
+ is_string: false,
191
+ default_value: false
192
+ ),
193
+ FastlaneCore::ConfigItem.new(
194
+ key: :destinations,
195
+ description: "Use custom destinations for building the xcframework",
196
+ optional: true,
197
+ is_string: false,
198
+ default_value: ['iOS']
199
+ ),
200
+ FastlaneCore::ConfigItem.new(
201
+ key: :xcframework_output_directory,
202
+ description: "The directory in which the xcframework should be stored in",
203
+ optional: true
204
+ ),
205
+ FastlaneCore::ConfigItem.new(
206
+ key: :product_name,
207
+ description: "The name of your module. Optional if equals to :scheme. Equivalent to CFBundleName",
208
+ optional: true
209
+ )
210
+ ]
211
+ end
212
+
213
+ def self.category
214
+ :building
215
+ end
216
+
217
+ def self.is_supported?(platform)
218
+ [:ios, :mac].include?(platform)
219
+ end
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,78 @@
1
+ module Fastlane
2
+ module Helper
3
+ class CreateXcframeworkHelper
4
+ def initialize(params)
5
+ @params = params
6
+ end
7
+
8
+ def product_name
9
+ @params[:product_name] ||= @params[:scheme]
10
+ end
11
+
12
+ def xcframework
13
+ "#{product_name}.xcframework"
14
+ end
15
+
16
+ def framework
17
+ "#{product_name}.framework"
18
+ end
19
+
20
+ def xcarchive_path(framework_index)
21
+ "#{framework_index}_#{product_name}.xcarchive"
22
+ end
23
+
24
+ def xcarchive_framework_path(framework_index)
25
+ framework_path = "#{xcarchive_path(framework_index)}/Products/Library/Frameworks/#{framework}"
26
+ return framework_path if File.exist?(framework_path)
27
+
28
+ FastlaneCore::UI.user_error!("â–¸ PRODUCT_NAME was misdefined: `#{product_name}`. Please, provide :product_name option")
29
+ end
30
+
31
+ def xcarchive_frameworks_path
32
+ @params[:destinations].each_with_index.map { |_, i| xcarchive_framework_path(i) }
33
+ end
34
+
35
+ def xcarchive_dSYMs_path(framework_index)
36
+ "#{xcarchive_path(framework_index)}/dSYMS"
37
+ end
38
+
39
+ def xcframework_dSYMs_path
40
+ "#{output_directory}/#{product_name}.dSYMs"
41
+ end
42
+
43
+ def xcarchive_BCSymbolMaps_path(framework_index)
44
+ "#{xcarchive_path(framework_index)}/BCSymbolMaps"
45
+ end
46
+
47
+ def xcframework_BCSymbolMaps_path
48
+ "#{output_directory}/#{product_name}.BCSymbolMaps"
49
+ end
50
+
51
+ def xcframework_path
52
+ "#{output_directory}/#{xcframework}"
53
+ end
54
+
55
+ def output_directory
56
+ @params[:xcframework_output_directory] ? @params[:xcframework_output_directory] : ''
57
+ end
58
+
59
+ def library_identifier(framework_index)
60
+ framework_path = xcarchive_framework_path(framework_index)
61
+ framework_basename = framework_path.split('/').last
62
+ framework_root = framework_basename.split('.').first
63
+ library_identifiers = Dir.chdir(xcframework_path) do
64
+ Dir.glob('*').select { |f| File.directory?(f) }
65
+ end
66
+ library_identifier = library_identifiers.detect do |id|
67
+ FileUtils.compare_file(
68
+ "#{framework_path}/#{framework_root}",
69
+ "#{xcframework_path}/#{id}/#{framework_basename}/#{framework_root}"
70
+ )
71
+ end
72
+ UI.user_error!("Error: #{xcframework_path} doesn't contain #{framework_path}") if library_identifier.nil?
73
+
74
+ library_identifier
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module CreateXcframework
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-create_xcframework
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Boris Bielik
8
+ - Alexey Alter-Pesotskiy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-06-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pry
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec_junit_formatter
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rubocop
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '='
89
+ - !ruby/object:Gem::Version
90
+ version: 0.49.1
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '='
96
+ - !ruby/object:Gem::Version
97
+ version: 0.49.1
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop-require_tools
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: simplecov
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: fastlane
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 2.144.0
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 2.144.0
140
+ description: Fastlane plugin that creates xcframework for given list of destinations.
141
+ email:
142
+ - bielik.boris@gmail.com
143
+ - a.alterpesotskiy@mail.ru
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - LICENSE
149
+ - README.md
150
+ - lib/fastlane/plugin/create_xcframework.rb
151
+ - lib/fastlane/plugin/create_xcframework/actions/create_xcframework_action.rb
152
+ - lib/fastlane/plugin/create_xcframework/helper/create_xcframework_helper.rb
153
+ - lib/fastlane/plugin/create_xcframework/version.rb
154
+ homepage: https://github.com/bielikb/fastlane-plugin-create_xcframework
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubygems_version: 3.0.3
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: Fastlane plugin that creates xcframework for given list of destinations.
177
+ test_files: []