fastlane-plugin-mobile_tools 0.1.1 → 0.1.2
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 +4 -4
- data/lib/fastlane/plugin/mobile_tools/actions/create_xcframework_action.rb +56 -18
- data/lib/fastlane/plugin/mobile_tools/actions/validate_xcframework_action.rb +105 -0
- data/lib/fastlane/plugin/mobile_tools/helper/validate_xcframework_helper.rb +142 -0
- data/lib/fastlane/plugin/mobile_tools/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b8d5653d4f3f3b10d79db61208cd9f31b0fd9a30bd048303897e246d349120b
|
4
|
+
data.tar.gz: ece53b29c54071b28807c757c0c1157ae53846e09463e719b1c2ec3d4ee9b7d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a6d6a9d84e45d400121a5bb9fa9b4c99bffa221656fce87c80813db1acfdff46edc589139afe1e02289156fbfb9677aecba7580416dff37e5c8c285b9e023a9
|
7
|
+
data.tar.gz: c0bb6fb42a97af43acdb7c2a6e39e2fa3edea90737fa0b4520b4fb395d0b2364fb87adb5f9fc59c117140b213d2db884afb93d186957b435ffbba23f403ddf4b
|
@@ -26,6 +26,7 @@ module Fastlane
|
|
26
26
|
end
|
27
27
|
|
28
28
|
create_xcframework(params)
|
29
|
+
|
29
30
|
remove_module_reference(params)
|
30
31
|
sign_xcframework(params)
|
31
32
|
zip_xcframework(params)
|
@@ -114,7 +115,7 @@ module Fastlane
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def self.sign_xcframework(params)
|
117
|
-
return if params[:code_sign_identity].nil?
|
118
|
+
return if params[:code_sign_identity].nil? || params[:code_sign_identity] == false
|
118
119
|
|
119
120
|
frameworks = params[:frameworks] || [nil]
|
120
121
|
|
@@ -132,8 +133,9 @@ module Fastlane
|
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
136
|
+
require 'tmpdir'
|
135
137
|
def self.zip_xcframework(params)
|
136
|
-
return if params[:zip_xcframework].nil?
|
138
|
+
return if params[:zip_xcframework].nil? || params[:zip_xcframework] == false
|
137
139
|
|
138
140
|
# Check if the zip utility is installed
|
139
141
|
unless system("which zip > /dev/null 2>&1")
|
@@ -143,26 +145,57 @@ module Fastlane
|
|
143
145
|
|
144
146
|
frameworks = params[:frameworks] || [nil]
|
145
147
|
|
146
|
-
|
147
|
-
|
148
|
-
|
148
|
+
if params[:combine_all_zip]
|
149
|
+
Dir.mktmpdir do |tmpdir|
|
150
|
+
frameworks.each do |framework|
|
151
|
+
xcframework = framework ? @xchelper.get_xcframework_path(framework) : @xchelper.xcframework_path
|
152
|
+
UI.message("▸ Copying xcframework at path: #{xcframework} to tmp directory")
|
153
|
+
FileUtils.cp_r(xcframework, tmpdir)
|
154
|
+
end
|
155
|
+
|
156
|
+
combined_zip_path = File.join(tmpdir, 'combined_xcframeworks.zip')
|
157
|
+
UI.message("▸ Listing all files in tmp directory")
|
158
|
+
UI.message(Dir.entries(tmpdir))
|
159
|
+
|
160
|
+
Dir.chdir(tmpdir) do
|
161
|
+
command = "zip -r -X #{combined_zip_path} ."
|
162
|
+
UI.message("▸ Zipping all xcframeworks into one zip at path: #{combined_zip_path}")
|
163
|
+
UI.message(command)
|
164
|
+
|
165
|
+
begin
|
166
|
+
Actions.sh(command)
|
167
|
+
rescue StandardError => e
|
168
|
+
UI.user_error!(e)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
output_directory = params[:output_directory] || '.'
|
173
|
+
final_zip_path = File.join(output_directory, 'combined_xcframeworks.zip')
|
174
|
+
FileUtils.mv(combined_zip_path, final_zip_path)
|
175
|
+
UI.message("▸ Moved combined zip to output directory at path: #{final_zip_path}")
|
176
|
+
end
|
177
|
+
else
|
178
|
+
frameworks.each do |framework|
|
179
|
+
xcframework = framework ? @xchelper.get_xcframework_path(framework) : @xchelper.xcframework_path
|
149
180
|
|
150
|
-
|
151
|
-
|
152
|
-
|
181
|
+
UI.message("▸ Zipping xcframework at path: #{xcframework}")
|
182
|
+
begin
|
183
|
+
zip_path = "#{xcframework}.zip"
|
184
|
+
FileUtils.rm_f(zip_path) if File.exist?(zip_path)
|
153
185
|
|
154
|
-
|
155
|
-
|
186
|
+
command = "zip -r -X #{zip_path} #{xcframework}"
|
187
|
+
UI.message(command)
|
156
188
|
|
157
|
-
|
158
|
-
|
159
|
-
|
189
|
+
Actions.sh(command)
|
190
|
+
rescue StandardError => e
|
191
|
+
UI.user_error!(e)
|
192
|
+
end
|
160
193
|
end
|
161
194
|
end
|
162
195
|
end
|
163
196
|
|
164
197
|
def self.delete_xcframework(params)
|
165
|
-
return if params[:delete_xcframework].nil?
|
198
|
+
return if params[:delete_xcframework].nil? || params[:delete_xcframework] == false
|
166
199
|
|
167
200
|
frameworks = params[:frameworks] || [nil]
|
168
201
|
|
@@ -178,13 +211,11 @@ module Fastlane
|
|
178
211
|
end
|
179
212
|
end
|
180
213
|
|
181
|
-
|
182
|
-
|
183
214
|
# #Fix compile problem go to xcframework and run this command (https://developer.apple.com/forums/thread/123253):
|
184
215
|
# #The generated file includes many module references that Swift thinks are class references because it uses the class ahead of the module
|
185
216
|
# #The problem is that in the Swiftinterface file, we have a class named ABCConnections, but the module is also called ABCConnections.
|
186
217
|
def self.remove_module_reference(params)
|
187
|
-
return if params[:ignore_module_reference].nil?
|
218
|
+
return if params[:ignore_module_reference].nil? || params[:ignore_module_reference] == false
|
188
219
|
|
189
220
|
frameworks = params[:frameworks] || [nil]
|
190
221
|
|
@@ -355,7 +386,7 @@ module Fastlane
|
|
355
386
|
end
|
356
387
|
|
357
388
|
def self.authors
|
358
|
-
['
|
389
|
+
['ykhandelwal']
|
359
390
|
end
|
360
391
|
|
361
392
|
def self.details
|
@@ -458,8 +489,15 @@ module Fastlane
|
|
458
489
|
description: 'Delete the xcframework after creation',
|
459
490
|
optional: true,
|
460
491
|
default_value: false
|
492
|
+
),
|
493
|
+
FastlaneCore::ConfigItem.new(
|
494
|
+
key: :combine_all_zip,
|
495
|
+
description: 'Combine all xcframeworks into one zip file',
|
496
|
+
optional: true,
|
497
|
+
default_value: false
|
461
498
|
)
|
462
499
|
]
|
500
|
+
|
463
501
|
end
|
464
502
|
|
465
503
|
def self.category
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class ValidateXcframeworkAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
validate_xcframework(params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.validate_xcframework(params)
|
9
|
+
return if params[:validate_xcframework].nil? || params[:validate_xcframework] == false
|
10
|
+
|
11
|
+
UI.message("▸ Validating xcframework")
|
12
|
+
xcframework_paths = []
|
13
|
+
|
14
|
+
frameworks = params[:frameworks] || [nil]
|
15
|
+
|
16
|
+
@xchelper = Helper::CreateXcframeworkHelper.new(params)
|
17
|
+
frameworks.each do |framework|
|
18
|
+
xcframework = framework ? @xchelper.get_xcframework_path(framework) : @xchelper.xcframework_path
|
19
|
+
xcframework_paths << xcframework
|
20
|
+
end
|
21
|
+
|
22
|
+
UI.message("▸ Creating temporary sample app")
|
23
|
+
sample_app_path = Helper::ValidateXcframeworkHelper.create_sample_app(xcframework_paths)
|
24
|
+
|
25
|
+
UI.message("▸ Building the sample app to validate xcframework")
|
26
|
+
begin
|
27
|
+
Dir.chdir(sample_app_path) do
|
28
|
+
Actions.sh("swift build")
|
29
|
+
UI.success("xcframework validation succeeded")
|
30
|
+
end
|
31
|
+
rescue StandardError => e
|
32
|
+
UI.user_error!("xcframework validation failed: #{e}")
|
33
|
+
end
|
34
|
+
|
35
|
+
UI.message("▸ Creating project.yml for xcodegen")
|
36
|
+
project_yml_path = Helper::ValidateXcframeworkHelper.create_project_yml(xcframework_paths, sample_app_path)
|
37
|
+
|
38
|
+
UI.message("▸ Generating Xcode project using xcodegen")
|
39
|
+
begin
|
40
|
+
Helper::ValidateXcframeworkHelper.generate_xcode_project(project_yml_path)
|
41
|
+
UI.success("Xcode project generated successfully with xcodegen")
|
42
|
+
rescue StandardError => e
|
43
|
+
UI.user_error!("Failed to generate Xcode project with xcodegen: #{e}")
|
44
|
+
end
|
45
|
+
|
46
|
+
UI.message("▸ Building the Xcode project to validate xcframework")
|
47
|
+
xcodeproj_path = File.join(sample_app_path, 'SampleApp.xcodeproj')
|
48
|
+
begin
|
49
|
+
Helper::ValidateXcframeworkHelper.build_xcode_project(xcodeproj_path)
|
50
|
+
UI.success("xcframework validation succeeded with xcodebuild")
|
51
|
+
rescue StandardError => e
|
52
|
+
UI.user_error!("xcframework validation failed with xcodebuild: #{e}")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.run_swiftlint
|
57
|
+
UI.message("▸ Running SwiftLint")
|
58
|
+
begin
|
59
|
+
Actions.sh("if which swiftlint >/dev/null; then swiftlint; else echo 'warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint'; fi")
|
60
|
+
UI.success("SwiftLint check completed successfully")
|
61
|
+
rescue StandardError => e
|
62
|
+
UI.user_error!("SwiftLint check failed: #{e}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.description
|
67
|
+
"Validate xcframework and run SwiftLint"
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.authors
|
71
|
+
["Your Name"]
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.return_value
|
75
|
+
# If your method provides a return value, you can describe it here
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.details
|
79
|
+
# Optional:
|
80
|
+
"This action validates an xcframework by creating a temporary sample app, building it, and running SwiftLint."
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.available_options
|
84
|
+
[
|
85
|
+
FastlaneCore::ConfigItem.new(key: :frameworks,
|
86
|
+
description: "Paths to the frameworks to be validated",
|
87
|
+
optional: false,
|
88
|
+
type: Array),
|
89
|
+
FastlaneCore::ConfigItem.new(key: :validate_xcframework,
|
90
|
+
description: "Flag to validate xcframework",
|
91
|
+
optional: true,
|
92
|
+
type: Boolean),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :xcframework_output_directory,
|
94
|
+
description: "Output directory for the xcframework",
|
95
|
+
optional: true,
|
96
|
+
type: String)
|
97
|
+
]
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.is_supported?(platform)
|
101
|
+
true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Helper
|
3
|
+
class ValidateXcframeworkHelper
|
4
|
+
def self.create_sample_app(framework_paths)
|
5
|
+
tmpdir = Dir.mktmpdir
|
6
|
+
sample_app_path = File.join(tmpdir, 'SampleApp')
|
7
|
+
Dir.mkdir(sample_app_path)
|
8
|
+
Dir.chdir(sample_app_path) do
|
9
|
+
system("swift package init --type executable")
|
10
|
+
tests_path = File.join(sample_app_path, 'Tests', 'SampleAppTests')
|
11
|
+
FileUtils.mkdir_p(tests_path)
|
12
|
+
|
13
|
+
# Copy frameworks to the temporary sample app folder
|
14
|
+
framework_paths.each do |path|
|
15
|
+
FileUtils.cp_r(path, sample_app_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
package_swift_path = File.join(sample_app_path, 'Package.swift')
|
19
|
+
# Extract names from framework paths and ensure paths are relative
|
20
|
+
binary_targets = framework_paths.map do |path|
|
21
|
+
name = File.basename(path, ".framework")
|
22
|
+
relative_path = "./" + File.basename(path)
|
23
|
+
".binaryTarget(name: \"#{name}\", path: \"#{relative_path}\")"
|
24
|
+
end.join(",\n ")
|
25
|
+
|
26
|
+
# Create dependencies for SampleApp target
|
27
|
+
dependencies = framework_paths.map do |path|
|
28
|
+
name = File.basename(path, ".framework")
|
29
|
+
"\"#{name}\""
|
30
|
+
end.join(", ")
|
31
|
+
|
32
|
+
resources = framework_paths.map do |path|
|
33
|
+
name = File.basename(path, ".framework")
|
34
|
+
".copy(\"./#{name}.framework\")"
|
35
|
+
end.join(",\n ")
|
36
|
+
|
37
|
+
# Add all framework names to the products target
|
38
|
+
product_targets = framework_paths.map do |path|
|
39
|
+
name = File.basename(path, ".framework")
|
40
|
+
"\"#{name}\""
|
41
|
+
end.join(", ")
|
42
|
+
|
43
|
+
package_swift_content = <<-SWIFT
|
44
|
+
// swift-tools-version:5.3
|
45
|
+
import PackageDescription
|
46
|
+
|
47
|
+
let package = Package(
|
48
|
+
name: "SampleApp",
|
49
|
+
platforms: [
|
50
|
+
.macOS(.v10_15),
|
51
|
+
.iOS(.v13)
|
52
|
+
],
|
53
|
+
products: [
|
54
|
+
.executable(name: "SampleApp", targets: ["SampleApp", #{product_targets}]),
|
55
|
+
],
|
56
|
+
dependencies: [
|
57
|
+
// Add dependencies here
|
58
|
+
],
|
59
|
+
targets: [
|
60
|
+
#{binary_targets},
|
61
|
+
.target(
|
62
|
+
name: "SampleApp",
|
63
|
+
dependencies: [#{dependencies}],
|
64
|
+
path: "Sources",
|
65
|
+
resources: [
|
66
|
+
#{resources}
|
67
|
+
]
|
68
|
+
),
|
69
|
+
.testTarget(
|
70
|
+
name: "SampleAppTests",
|
71
|
+
dependencies: ["SampleApp"],
|
72
|
+
path: "Tests/SampleAppTests"
|
73
|
+
),
|
74
|
+
]
|
75
|
+
)
|
76
|
+
SWIFT
|
77
|
+
|
78
|
+
File.write(package_swift_path, package_swift_content.strip)
|
79
|
+
end
|
80
|
+
sample_app_path
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.create_project_yml(framework_paths, sample_app_path)
|
84
|
+
project_yml_content = {
|
85
|
+
"name" => "SampleApp",
|
86
|
+
"options" => {
|
87
|
+
"bundleIdPrefix" => "com.intuit"
|
88
|
+
},
|
89
|
+
"targets" => {
|
90
|
+
"SampleApp" => {
|
91
|
+
"type" => "application",
|
92
|
+
"platform" => "iOS",
|
93
|
+
"deploymentTarget" => "13.0",
|
94
|
+
"sources" => ["Sources"],
|
95
|
+
"resources" => framework_paths.map { |path| "./#{File.basename(path)}" },
|
96
|
+
"dependencies" => framework_paths.map { |path| { "framework" => "./#{File.basename(path)}", "embed" => true } },
|
97
|
+
"settings" => {
|
98
|
+
"base" => {
|
99
|
+
"DEVELOPMENT_TEAM" => "F6DWWXWEX6",
|
100
|
+
"GENERATE_INFOPLIST_FILE" => "YES",
|
101
|
+
"CODE_SIGN_IDENTITY" => "iPhone Developer",
|
102
|
+
"LD_RUNPATH_SEARCH_PATHS" => ["$(inherited)", "@executable_path/Frameworks"],
|
103
|
+
"SDKROOT" => "iphoneos",
|
104
|
+
"TARGETED_DEVICE_FAMILY" => "1,2",
|
105
|
+
"VERSIONING_SYSTEM" => "apple-generic",
|
106
|
+
"CURRENT_PROJECT_VERSION" => "1",
|
107
|
+
"MARKETING_VERSION" => "1.0",
|
108
|
+
"CFBundleVersion" => "$(CURRENT_PROJECT_VERSION)",
|
109
|
+
"CFBundleShortVersionString" => "$(MARKETING_VERSION)"
|
110
|
+
},
|
111
|
+
"configs" => {
|
112
|
+
"debug" => {
|
113
|
+
"CODE_SIGN_STYLE" => "Manual",
|
114
|
+
"PROVISIONING_PROFILE_SPECIFIER" => "com.intuit.*.InHouse",
|
115
|
+
"CODE_SIGN_IDENTITY" => "iPhone Distribution: Intuit Inc.(Ent)"
|
116
|
+
},
|
117
|
+
"release" => {
|
118
|
+
"CODE_SIGN_STYLE" => "Manual",
|
119
|
+
"PROVISIONING_PROFILE_SPECIFIER" => "com.intuit.*.InHouse",
|
120
|
+
"CODE_SIGN_IDENTITY" => "iPhone Distribution: Intuit Inc.(Ent)"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
project_yml_path = File.join(sample_app_path, 'project.yml')
|
129
|
+
File.write(project_yml_path, project_yml_content.to_yaml)
|
130
|
+
project_yml_path
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.generate_xcode_project(project_yml_path)
|
134
|
+
Actions.sh("xcodegen generate --spec #{project_yml_path}")
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.build_xcode_project(xcodeproj_path)
|
138
|
+
Actions.sh("xcodebuild -project #{xcodeproj_path} -scheme SampleApp -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' build")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-mobile_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yogesh Khandelwal
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -192,7 +192,7 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
-
description:
|
195
|
+
description:
|
196
196
|
email: yogesh_khandelwal@intuit.com
|
197
197
|
executables: []
|
198
198
|
extensions: []
|
@@ -202,13 +202,15 @@ files:
|
|
202
202
|
- README.md
|
203
203
|
- lib/fastlane/plugin/mobile_tools.rb
|
204
204
|
- lib/fastlane/plugin/mobile_tools/actions/create_xcframework_action.rb
|
205
|
+
- lib/fastlane/plugin/mobile_tools/actions/validate_xcframework_action.rb
|
205
206
|
- lib/fastlane/plugin/mobile_tools/helper/create_xcframework_helper.rb
|
207
|
+
- lib/fastlane/plugin/mobile_tools/helper/validate_xcframework_helper.rb
|
206
208
|
- lib/fastlane/plugin/mobile_tools/version.rb
|
207
209
|
homepage: https://github.com/ykhandelwal913/fastlane-plugin-mobile_tools
|
208
210
|
licenses:
|
209
211
|
- MIT
|
210
212
|
metadata: {}
|
211
|
-
post_install_message:
|
213
|
+
post_install_message:
|
212
214
|
rdoc_options: []
|
213
215
|
require_paths:
|
214
216
|
- lib
|
@@ -223,8 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
225
|
- !ruby/object:Gem::Version
|
224
226
|
version: '0'
|
225
227
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
227
|
-
signing_key:
|
228
|
+
rubygems_version: 3.2.3
|
229
|
+
signing_key:
|
228
230
|
specification_version: 4
|
229
231
|
summary: fastlane plugin for mobile devops tooling
|
230
232
|
test_files: []
|