gonative-cli 1.5.6 → 2.0.0
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/Gemfile.lock +33 -21
- data/lib/gonative/commands/ios/build.rb +19 -0
- data/lib/gonative/commands/ios/publish.rb +20 -5
- data/lib/gonative/commands/ios/version.rb +3 -5
- data/lib/gonative/commands.rb +1 -0
- data/lib/gonative/plugins/ios/build_framework.rb +223 -117
- data/lib/gonative/plugins/ios/create.rb +5 -2
- data/lib/gonative/plugins/ios/release.rb +162 -24
- data/lib/gonative/plugins/ios/verify.rb +1 -7
- data/lib/gonative/plugins/ios/version.rb +8 -8
- data/lib/gonative/utils/template_inflator.rb +8 -4
- data/lib/gonative/utils.rb +1 -1
- data/lib/gonative/version.rb +1 -1
- data/templates/plugins/android/plugin-metadata.json.erb +7 -0
- data/templates/plugins/android/src/main/{AndroidManifest.xml.tpl → AndroidManifest.xml.erb} +2 -2
- data/templates/plugins/android/src/main/java/io/gonative/android/plugins/JAVA_PACKAGE/{PLUGIN_NAME.java.tpl → PLUGIN_NAME.java.erb} +3 -3
- data/templates/plugins/ios/common/Package.swift.erb +28 -0
- data/templates/plugins/ios/common/Project.swift.erb +44 -0
- data/templates/plugins/ios/common/Resources/polyfill.js.erb +10 -0
- data/templates/plugins/ios/common/VERSION +1 -0
- data/templates/plugins/ios/common/Wrappers/dummy.m +1 -0
- data/templates/plugins/ios/common/Wrappers/include/dummy.h +1 -0
- data/templates/plugins/ios/language-specific/objc/{PLUGIN_NAME/Classes/GNPLUGIN_NAME.h.tpl → Classes/GNPLUGIN_NAME.h.erb} +4 -4
- data/templates/plugins/ios/language-specific/objc/Classes/GNPLUGIN_NAME.m.erb +14 -0
- data/templates/plugins/ios/language-specific/objc/Project.swift.erb +44 -0
- data/templates/plugins/ios/language-specific/swift/Classes/GNSwiftModule.m.erb +12 -0
- data/templates/plugins/ios/language-specific/swift/Classes/GNSwiftModule.swift.erb +14 -0
- data/templates/plugins/ios/language-specific/swift/Project.swift.erb +43 -0
- metadata +22 -25
- data/lib/gonative/utils/content_evaluator.rb +0 -16
- data/templates/build/ios/Info.plist +0 -28
- data/templates/build/ios/PLUGIN_NAME-umbrella.h.tpl +0 -16
- data/templates/build/ios/PLUGIN_NAME.modulemap.tpl +0 -6
- data/templates/build/ios/Podfile.tpl +0 -10
- data/templates/build/ios/create-framework.sh.tpl +0 -36
- data/templates/plugins/android/plugin-metadata.json.tpl +0 -7
- data/templates/plugins/ios/common/PLUGIN_NAME/Classes/Dummy.swift +0 -6
- data/templates/plugins/ios/common/PLUGIN_NAME/Resources/polyfill.js.tpl +0 -0
- data/templates/plugins/ios/common/PLUGIN_NAME.podspec.tpl +0 -30
- data/templates/plugins/ios/language-specific/objc/PLUGIN_NAME/Classes/GNPLUGIN_NAME.m.tpl +0 -14
- data/templates/plugins/ios/language-specific/swift/PLUGIN_NAME/Classes/GNSwiftModule.m.tpl +0 -12
- data/templates/plugins/ios/language-specific/swift/PLUGIN_NAME/Classes/GNSwiftModule.swift.tpl +0 -14
- /data/templates/plugins/ios/common/{PLUGIN_NAME/Frameworks → Frameworks}/.keep +0 -0
- /data/templates/plugins/ios/common/{PLUGIN_NAME/Info.plist → Info.plist} +0 -0
- /data/templates/plugins/ios/common/{PLUGIN_NAME/LICENSE → LICENSE} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35dc9f759236d6b1ac5b65b11b0bb90577d288cc1b160298762adab4d782ccba
|
|
4
|
+
data.tar.gz: 4db543701fb3d94aaec48058e789ef111264dd5ce2cbba27af8e6a02f5a779e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2df712fbb8e67d33e10006997cbf6a91a9be077fcc05caed72f6a818a26f3bd6f6cf112727ce9cd7fd5423c4dc0c154c8b5e0a6d66aaf29f23222a4a3bd1a558
|
|
7
|
+
data.tar.gz: 336b11316a7647516d16c1c5c302f0b508420682a864d45ddd9b5ba789d542e5f7799a5f6093b0f1bf7fe7c33aa743b7c289ec45b3697b854ac41bb8911f722b
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gonative-cli (
|
|
4
|
+
gonative-cli (2.0.0)
|
|
5
5
|
activesupport (~> 6.0)
|
|
6
6
|
aws-sdk-s3 (~> 1)
|
|
7
7
|
cocoapods (~> 1.10)
|
|
@@ -14,9 +14,8 @@ PATH
|
|
|
14
14
|
GEM
|
|
15
15
|
remote: https://rubygems.org/
|
|
16
16
|
specs:
|
|
17
|
-
CFPropertyList (3.0.
|
|
18
|
-
|
|
19
|
-
activesupport (6.1.7)
|
|
17
|
+
CFPropertyList (3.0.8)
|
|
18
|
+
activesupport (6.1.7.10)
|
|
20
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
21
20
|
i18n (>= 1.6, < 2)
|
|
22
21
|
minitest (>= 5.1)
|
|
@@ -29,22 +28,27 @@ GEM
|
|
|
29
28
|
json (>= 1.5.1)
|
|
30
29
|
ast (2.4.2)
|
|
31
30
|
atomos (0.1.3)
|
|
32
|
-
aws-eventstream (1.
|
|
33
|
-
aws-partitions (1.
|
|
34
|
-
aws-sdk-core (3.
|
|
31
|
+
aws-eventstream (1.4.0)
|
|
32
|
+
aws-partitions (1.1231.0)
|
|
33
|
+
aws-sdk-core (3.244.0)
|
|
35
34
|
aws-eventstream (~> 1, >= 1.3.0)
|
|
36
35
|
aws-partitions (~> 1, >= 1.992.0)
|
|
37
36
|
aws-sigv4 (~> 1.9)
|
|
37
|
+
base64
|
|
38
|
+
bigdecimal
|
|
38
39
|
jmespath (~> 1, >= 1.6.1)
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
logger
|
|
41
|
+
aws-sdk-kms (1.123.0)
|
|
42
|
+
aws-sdk-core (~> 3, >= 3.244.0)
|
|
41
43
|
aws-sigv4 (~> 1.5)
|
|
42
|
-
aws-sdk-s3 (1.
|
|
43
|
-
aws-sdk-core (~> 3, >= 3.
|
|
44
|
+
aws-sdk-s3 (1.217.0)
|
|
45
|
+
aws-sdk-core (~> 3, >= 3.244.0)
|
|
44
46
|
aws-sdk-kms (~> 1)
|
|
45
47
|
aws-sigv4 (~> 1.5)
|
|
46
|
-
aws-sigv4 (1.
|
|
48
|
+
aws-sigv4 (1.12.1)
|
|
47
49
|
aws-eventstream (~> 1, >= 1.0.2)
|
|
50
|
+
base64 (0.3.0)
|
|
51
|
+
bigdecimal (4.0.1)
|
|
48
52
|
byebug (11.1.3)
|
|
49
53
|
claide (1.1.0)
|
|
50
54
|
cocoapods (1.15.2)
|
|
@@ -89,28 +93,36 @@ GEM
|
|
|
89
93
|
colorize (0.8.1)
|
|
90
94
|
concurrent-ruby (1.3.4)
|
|
91
95
|
diff-lcs (1.4.4)
|
|
96
|
+
drb (2.2.3)
|
|
92
97
|
dry-cli (0.7.0)
|
|
93
98
|
escape (0.0.4)
|
|
94
|
-
ethon (0.
|
|
99
|
+
ethon (0.18.0)
|
|
95
100
|
ffi (>= 1.15.0)
|
|
96
|
-
|
|
101
|
+
logger
|
|
102
|
+
ffi (1.17.2-arm64-darwin)
|
|
97
103
|
fourflusher (2.3.1)
|
|
98
104
|
fuzzy_match (2.0.4)
|
|
99
105
|
gh_inspector (1.1.3)
|
|
100
|
-
httpclient (2.
|
|
101
|
-
|
|
106
|
+
httpclient (2.9.0)
|
|
107
|
+
mutex_m
|
|
108
|
+
i18n (1.14.8)
|
|
102
109
|
concurrent-ruby (~> 1.0)
|
|
103
110
|
jmespath (1.6.2)
|
|
104
|
-
json (2.
|
|
111
|
+
json (2.19.3)
|
|
112
|
+
logger (1.7.0)
|
|
105
113
|
method_source (1.0.0)
|
|
106
|
-
minitest (
|
|
114
|
+
minitest (6.0.2)
|
|
115
|
+
drb (~> 2.0)
|
|
116
|
+
prism (~> 1.5)
|
|
107
117
|
molinillo (0.8.0)
|
|
118
|
+
mutex_m (0.3.0)
|
|
108
119
|
nanaimo (0.3.0)
|
|
109
120
|
nap (1.1.0)
|
|
110
121
|
netrc (0.11.0)
|
|
111
122
|
parallel (1.20.1)
|
|
112
123
|
parser (3.0.2.0)
|
|
113
124
|
ast (~> 2.4.1)
|
|
125
|
+
prism (1.9.0)
|
|
114
126
|
pry (0.13.1)
|
|
115
127
|
coderay (~> 1.1)
|
|
116
128
|
method_source (~> 1.0)
|
|
@@ -151,19 +163,19 @@ GEM
|
|
|
151
163
|
rubocop-ast (>= 0.4.0)
|
|
152
164
|
ruby-macho (2.5.1)
|
|
153
165
|
ruby-progressbar (1.11.0)
|
|
154
|
-
typhoeus (1.4.
|
|
166
|
+
typhoeus (1.4.1)
|
|
155
167
|
ethon (>= 0.9.0)
|
|
156
168
|
tzinfo (2.0.6)
|
|
157
169
|
concurrent-ruby (~> 1.0)
|
|
158
170
|
unicode-display_width (2.0.0)
|
|
159
|
-
xcodeproj (1.
|
|
171
|
+
xcodeproj (1.24.0)
|
|
160
172
|
CFPropertyList (>= 2.3.3, < 4.0)
|
|
161
173
|
atomos (~> 0.1.3)
|
|
162
174
|
claide (>= 1.0.2, < 2.0)
|
|
163
175
|
colored2 (~> 3.1)
|
|
164
176
|
nanaimo (~> 0.3.0)
|
|
165
177
|
rexml (~> 3.2.4)
|
|
166
|
-
zeitwerk (2.
|
|
178
|
+
zeitwerk (2.7.5)
|
|
167
179
|
|
|
168
180
|
PLATFORMS
|
|
169
181
|
arm64-darwin-21
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GoNative
|
|
4
|
+
module Commands
|
|
5
|
+
module IOS
|
|
6
|
+
class Build < Base
|
|
7
|
+
desc 'Build a framework without releasing'
|
|
8
|
+
|
|
9
|
+
option :debug, type: :boolean, default: false, desc: 'Keep build directory for debugging'
|
|
10
|
+
option :archs, default: 'x86_64,arm64', desc: 'Comma-separated list of architectures to build'
|
|
11
|
+
|
|
12
|
+
def call(debug:, archs:, **)
|
|
13
|
+
Plugins::IOS::Verify.call
|
|
14
|
+
Plugins::IOS::BuildFramework.call(archs, debug)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -5,17 +5,32 @@ module GoNative
|
|
|
5
5
|
module IOS
|
|
6
6
|
class Publish < Base
|
|
7
7
|
autoload :FileUtils, 'fileutils'
|
|
8
|
-
desc 'Verify, build and release a new version'
|
|
8
|
+
desc 'Verify, build and release a new version to the SPM registry'
|
|
9
9
|
|
|
10
|
-
argument :
|
|
10
|
+
argument :version, required: false, desc: 'Version to publish (reads from VERSION file if omitted)'
|
|
11
11
|
option :skip_build, type: :boolean, default: false
|
|
12
12
|
option :debug, type: :boolean, default: false
|
|
13
13
|
option :archs, default: 'x86_64,arm64'
|
|
14
|
+
option :scope, default: 'median', desc: 'Package scope for the registry'
|
|
15
|
+
option :registry, default: 'https://packages.median.co', desc: 'SPM registry URL'
|
|
14
16
|
|
|
15
|
-
def call(
|
|
17
|
+
def call(version: nil, skip_build:, debug:, archs:, scope:, registry:, **)
|
|
18
|
+
version ||= read_version_file
|
|
16
19
|
Plugins::IOS::Verify.call
|
|
17
|
-
Plugins::IOS::BuildFramework.call(
|
|
18
|
-
Plugins::IOS::Release.call(
|
|
20
|
+
Plugins::IOS::BuildFramework.call(archs, debug) unless skip_build
|
|
21
|
+
Plugins::IOS::Release.call(version, scope: scope, registry_url: registry)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def read_version_file
|
|
27
|
+
path = File.join(Dir.pwd, 'VERSION')
|
|
28
|
+
unless File.exist?(path)
|
|
29
|
+
raise Error, 'No version specified and no VERSION file found'
|
|
30
|
+
end
|
|
31
|
+
File.read(path).strip.tap do |v|
|
|
32
|
+
raise Error, 'VERSION file is empty' if v.empty?
|
|
33
|
+
end
|
|
19
34
|
end
|
|
20
35
|
end
|
|
21
36
|
end
|
|
@@ -4,12 +4,10 @@ module GoNative
|
|
|
4
4
|
module Commands
|
|
5
5
|
module IOS
|
|
6
6
|
class Version < Base
|
|
7
|
-
desc 'Get version
|
|
7
|
+
desc 'Get version from VERSION file'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def call(podspec:, **)
|
|
12
|
-
Plugins::IOS::Version.call(podspec)
|
|
9
|
+
def call(**)
|
|
10
|
+
Plugins::IOS::Version.call
|
|
13
11
|
end
|
|
14
12
|
end
|
|
15
13
|
end
|
data/lib/gonative/commands.rb
CHANGED
|
@@ -6,6 +6,7 @@ module GoNative
|
|
|
6
6
|
|
|
7
7
|
register 'version', Version, aliases: %w[--version -v]
|
|
8
8
|
register 'ios create', IOS::Create
|
|
9
|
+
register 'ios build', IOS::Build
|
|
9
10
|
register 'ios publish', IOS::Publish
|
|
10
11
|
register 'ios extract-extensions', IOS::ExtractExtensions
|
|
11
12
|
register 'ios embed-extensions', IOS::EmbedExtensions
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'cocoapods'
|
|
4
|
+
require 'shellwords'
|
|
5
|
+
require 'pathname'
|
|
4
6
|
require 'xcodeproj'
|
|
5
|
-
require 'active_support/core_ext/string/inflections'
|
|
6
|
-
require 'aws-sdk-s3'
|
|
7
7
|
|
|
8
8
|
module GoNative
|
|
9
9
|
module Plugins
|
|
@@ -13,160 +13,266 @@ module GoNative
|
|
|
13
13
|
|
|
14
14
|
extend DSL::Serviceable
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
attr_reader :archs, :persist_build_dir, :project_root
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def initialize(podspec, archs, persist_build_dir)
|
|
21
|
-
raise Error, 'No podspec exists.' unless File.exist?(podspec)
|
|
22
|
-
|
|
23
|
-
@plugin_name = File.basename(podspec, '.podspec')
|
|
18
|
+
def initialize(archs, persist_build_dir, project_root = FileUtils.pwd)
|
|
24
19
|
@archs = archs.gsub(',', ' ')
|
|
25
20
|
@persist_build_dir = persist_build_dir
|
|
21
|
+
@project_root = File.expand_path(project_root)
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
def call
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
upload_to_s3
|
|
25
|
+
original_dir = FileUtils.pwd
|
|
26
|
+
|
|
27
|
+
raise Error, "No Project.swift found in #{project_root}" unless tuist_project?
|
|
28
|
+
|
|
29
|
+
build_framework_with_tuist!
|
|
35
30
|
ensure
|
|
36
|
-
FileUtils.cd(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def cd_build_dir
|
|
41
|
-
build_dir = File.join(FileUtils.pwd, 'build')
|
|
42
|
-
return false if File.exist?(build_dir)
|
|
43
|
-
|
|
44
|
-
FileUtils.mkdir(build_dir)
|
|
45
|
-
FileUtils.cd(build_dir)
|
|
46
|
-
true
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def setup_build_dir
|
|
50
|
-
create_framework_proj
|
|
51
|
-
move_template_files!
|
|
52
|
-
run_pod_install
|
|
53
|
-
chmod_frameworks_script!
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def create_framework_proj
|
|
57
|
-
proj = Xcodeproj::Project.new(FileUtils.pwd)
|
|
58
|
-
target = proj.new_target(:framework,
|
|
59
|
-
plugin_name.to_s,
|
|
60
|
-
:ios,
|
|
61
|
-
deployment_target)
|
|
62
|
-
main_group = proj.new_group(plugin_name, plugin_name)
|
|
63
|
-
add_classes(target, main_group)
|
|
64
|
-
add_frameworks(target, main_group)
|
|
65
|
-
add_headers(target, main_group)
|
|
66
|
-
target.build_configurations.each do |config|
|
|
67
|
-
config.build_settings['INFOPLIST_FILE'] = 'Info.plist'
|
|
68
|
-
config.build_settings['MARKETING_VERSION'] = spec.version
|
|
69
|
-
config.build_settings['MODULEMAP_FILE'] = "#{plugin_name}.modulemap"
|
|
70
|
-
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = "org.cocoapods.#{plugin_name}"
|
|
71
|
-
config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
|
|
72
|
-
end
|
|
73
|
-
proj.save("#{plugin_name}.xcodeproj")
|
|
31
|
+
FileUtils.cd(original_dir) if original_dir && File.directory?(original_dir)
|
|
32
|
+
cleanup_build_dir unless persist_build_dir
|
|
33
|
+
|
|
74
34
|
end
|
|
75
35
|
|
|
76
|
-
def
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
36
|
+
def build_framework_with_tuist!
|
|
37
|
+
FileUtils.cd(project_root)
|
|
38
|
+
FileUtils.mkdir_p(File.join('.build', 'Frameworks'))
|
|
39
|
+
generate_module_artifacts!
|
|
40
|
+
generate_tuist_project!
|
|
41
|
+
patch_generated_project!
|
|
42
|
+
archive_framework!
|
|
43
|
+
move_xcframework_to_frameworks!
|
|
82
44
|
end
|
|
83
45
|
|
|
84
|
-
def
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
46
|
+
def move_xcframework_to_frameworks!
|
|
47
|
+
Utils::UI.info 'Moving xcframework to Frameworks directory'
|
|
48
|
+
source = File.join(project_root, '.build', 'Frameworks', "#{plugin_name}.xcframework")
|
|
49
|
+
dest_dir = frameworks_dir
|
|
50
|
+
FileUtils.mkdir_p(dest_dir)
|
|
51
|
+
dest = File.join(dest_dir, "#{plugin_name}.xcframework")
|
|
52
|
+
FileUtils.rm_rf(dest) if File.exist?(dest)
|
|
53
|
+
FileUtils.cp_r(source, dest)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def frameworks_dir
|
|
57
|
+
File.join(project_root, 'Frameworks')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def tuist_project?
|
|
61
|
+
File.exist?(File.join(project_root, 'Project.swift'))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def plugin_name
|
|
65
|
+
@plugin_name ||= begin
|
|
66
|
+
project_definition = File.read(File.join(project_root, 'Project.swift'))
|
|
67
|
+
match = project_definition.match(/name:\s*"([^"]+)"/)
|
|
68
|
+
raise Error, "Could not determine project name from #{File.join(project_root, 'Project.swift')}" unless match
|
|
69
|
+
|
|
70
|
+
match[1]
|
|
88
71
|
end
|
|
89
|
-
|
|
72
|
+
end
|
|
90
73
|
|
|
91
|
-
|
|
74
|
+
def generate_module_artifacts!
|
|
75
|
+
Utils::UI.info 'Generating umbrella header and module map'
|
|
76
|
+
File.write(umbrella_header_path, umbrella_header_contents)
|
|
77
|
+
File.write(modulemap_path, modulemap_contents)
|
|
92
78
|
end
|
|
93
79
|
|
|
94
|
-
def
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
80
|
+
def generate_tuist_project!
|
|
81
|
+
Utils::UI.info 'Generating project with Tuist'
|
|
82
|
+
return if system('tuist generate --no-open')
|
|
83
|
+
|
|
84
|
+
raise Error, 'Error generating Tuist project'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def patch_generated_project!
|
|
88
|
+
Utils::UI.info 'Patching generated Xcode project'
|
|
89
|
+
project = Xcodeproj::Project.open(xcodeproj_path)
|
|
90
|
+
|
|
91
|
+
project.build_configurations.each do |config|
|
|
92
|
+
patch_build_settings!(config)
|
|
98
93
|
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
|
|
95
|
+
project.targets.select { |target| target.name == plugin_name }.each do |target|
|
|
96
|
+
ensure_public_umbrella_header!(project, target)
|
|
97
|
+
target.build_configurations.each do |config|
|
|
98
|
+
patch_build_settings!(config)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
project.save
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def patch_build_settings!(config)
|
|
106
|
+
config.build_settings.delete('SWIFT_OBJC_BRIDGING_HEADER')
|
|
107
|
+
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
|
|
108
|
+
config.build_settings['MODULEMAP_FILE'] = modulemap_project_setting_path
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def ensure_public_umbrella_header!(project, target)
|
|
112
|
+
relative_header_path = File.basename(umbrella_header_path)
|
|
113
|
+
file_reference = project.files.find { |file| file.path == relative_header_path } ||
|
|
114
|
+
project.main_group.new_file(relative_header_path)
|
|
115
|
+
|
|
116
|
+
build_file = target.headers_build_phase.files_references.find { |file| file.path == relative_header_path }
|
|
117
|
+
build_file ||= target.headers_build_phase.add_file_reference(file_reference, true)
|
|
118
|
+
build_file.settings = { 'ATTRIBUTES' => ['Public'] }
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def archive_framework!
|
|
122
|
+
FileUtils.rm_rf(simulator_archive_path)
|
|
123
|
+
FileUtils.rm_rf(device_archive_path)
|
|
124
|
+
|
|
125
|
+
return if system(archive_commands)
|
|
126
|
+
|
|
127
|
+
raise Error, 'Error building framework with Tuist. Please run the generated archive commands manually to inspect the failure'
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def archive_commands
|
|
131
|
+
[
|
|
132
|
+
xcodebuild_archive_command(
|
|
133
|
+
destination: "generic/platform=iOS Simulator",
|
|
134
|
+
archive_path: simulator_archive_path,
|
|
135
|
+
sdk: "iphonesimulator",
|
|
136
|
+
archs_override: true
|
|
137
|
+
),
|
|
138
|
+
xcodebuild_archive_command(
|
|
139
|
+
destination: "generic/platform=iOS",
|
|
140
|
+
archive_path: device_archive_path,
|
|
141
|
+
sdk: "iphoneos"
|
|
142
|
+
),
|
|
143
|
+
create_xcframework_command,
|
|
144
|
+
%(rm -rf #{Shellwords.escape(simulator_archive_path)} #{Shellwords.escape(device_archive_path)})
|
|
145
|
+
].join(' && ')
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def create_xcframework_command
|
|
149
|
+
%(xcodebuild -create-xcframework -framework #{Shellwords.escape(simulator_framework_path)} -debug-symbols #{Shellwords.escape(simulator_dsym_path)} -framework #{Shellwords.escape(device_framework_path)} -debug-symbols #{Shellwords.escape(device_dsym_path)} -output #{Shellwords.escape(xcframework_output_path)})
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def xcodebuild_archive_command(destination:, archive_path:, sdk:, archs_override: false)
|
|
153
|
+
command = [
|
|
154
|
+
"xcodebuild",
|
|
155
|
+
"-workspace #{Shellwords.escape(tuist_workspace_path)}",
|
|
156
|
+
"archive",
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
if archs_override
|
|
160
|
+
command << "ONLY_ACTIVE_ARCH=NO"
|
|
161
|
+
command << "ARCHS=#{Shellwords.escape(archs)}"
|
|
103
162
|
end
|
|
163
|
+
|
|
164
|
+
command.concat(
|
|
165
|
+
[
|
|
166
|
+
"-scheme #{Shellwords.escape(plugin_name)}",
|
|
167
|
+
%( -destination "#{destination}").strip,
|
|
168
|
+
"-archivePath #{Shellwords.escape(archive_path)}",
|
|
169
|
+
"-sdk #{Shellwords.escape(sdk)}",
|
|
170
|
+
"SKIP_INSTALL=NO",
|
|
171
|
+
]
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
command.join(" ")
|
|
104
175
|
end
|
|
105
176
|
|
|
106
|
-
def
|
|
107
|
-
|
|
108
|
-
["pod '#{d.name}'", "'#{d.requirement}'"].compact.join(', ')
|
|
109
|
-
end * "\n\t"
|
|
110
|
-
FileUtils.cp_r("#{BUILD_TEMPLATE_DIRECTORY_PATH}/.", '.')
|
|
111
|
-
headers = Dir.glob("../#{plugin_name}/Classes/**/*.h").map { |f| "#import \"#{File.basename(f)}\"" } * "\n"
|
|
112
|
-
Utils::TemplateInflator.new(plugin_name: plugin_name,
|
|
113
|
-
plugin_dependencies: plugin_dependencies,
|
|
114
|
-
plugin_headers: headers,
|
|
115
|
-
archs: archs,
|
|
116
|
-
deployment_target: deployment_target).call
|
|
177
|
+
def tuist_workspace_path
|
|
178
|
+
"#{plugin_name}.xcworkspace"
|
|
117
179
|
end
|
|
118
180
|
|
|
119
|
-
def
|
|
120
|
-
|
|
181
|
+
def simulator_archive_path
|
|
182
|
+
File.join('.build', 'Frameworks', 'simulator.xcarchive')
|
|
121
183
|
end
|
|
122
184
|
|
|
123
|
-
def
|
|
124
|
-
|
|
185
|
+
def device_archive_path
|
|
186
|
+
File.join('.build', 'Frameworks', 'iOS.xcarchive')
|
|
125
187
|
end
|
|
126
188
|
|
|
127
|
-
def
|
|
128
|
-
|
|
129
|
-
|
|
189
|
+
def xcframework_output_path
|
|
190
|
+
File.join('.build', 'Frameworks', "#{plugin_name}.xcframework")
|
|
191
|
+
end
|
|
130
192
|
|
|
131
|
-
|
|
193
|
+
def simulator_framework_path
|
|
194
|
+
File.expand_path(File.join(simulator_archive_path, 'Products', 'Library', 'Frameworks', "#{plugin_name}.framework"), project_root)
|
|
132
195
|
end
|
|
133
196
|
|
|
134
|
-
def
|
|
135
|
-
|
|
197
|
+
def device_framework_path
|
|
198
|
+
File.expand_path(File.join(device_archive_path, 'Products', 'Library', 'Frameworks', "#{plugin_name}.framework"), project_root)
|
|
136
199
|
end
|
|
137
200
|
|
|
138
|
-
def
|
|
139
|
-
|
|
140
|
-
included_paths = %w[Frameworks Resources LICENSE Info.plist Classes/Dummy.swift Extensions]
|
|
141
|
-
included_paths = included_paths.map { |path| "#{plugin_name}/#{path}" }
|
|
142
|
-
system "zip -r build/#{zip_file_name} " + included_paths.join(' ')
|
|
143
|
-
FileUtils.cd('build')
|
|
201
|
+
def simulator_dsym_path
|
|
202
|
+
File.expand_path(File.join(simulator_archive_path, 'dSYMs', "#{plugin_name}.framework.dSYM"), project_root)
|
|
144
203
|
end
|
|
145
204
|
|
|
146
|
-
def
|
|
147
|
-
"#{plugin_name}
|
|
205
|
+
def device_dsym_path
|
|
206
|
+
File.expand_path(File.join(device_archive_path, 'dSYMs', "#{plugin_name}.framework.dSYM"), project_root)
|
|
148
207
|
end
|
|
149
208
|
|
|
150
|
-
def
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
)
|
|
209
|
+
def cleanup_build_dir
|
|
210
|
+
FileUtils.rm_rf(File.join(project_root, '.build'))
|
|
211
|
+
FileUtils.rm_rf(File.join(project_root, "#{plugin_name}.xcodeproj"))
|
|
212
|
+
FileUtils.rm_rf(File.join(project_root, "#{plugin_name}.xcworkspace"))
|
|
213
|
+
FileUtils.rm_f(File.join(project_root, "#{plugin_name}.modulemap"))
|
|
214
|
+
FileUtils.rm_f(File.join(project_root, "#{plugin_name}-umbrella.h"))
|
|
215
|
+
end
|
|
156
216
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
key: "#{plugin_name}/#{zip_file_name}",
|
|
160
|
-
body: File.open(zip_file_name, 'rb')
|
|
161
|
-
)
|
|
217
|
+
def xcodeproj_path
|
|
218
|
+
File.join(project_root, "#{plugin_name}.xcodeproj")
|
|
162
219
|
end
|
|
163
220
|
|
|
164
|
-
def
|
|
165
|
-
|
|
221
|
+
def modulemap_path
|
|
222
|
+
File.join(project_root, "#{plugin_name}.modulemap")
|
|
166
223
|
end
|
|
167
224
|
|
|
168
|
-
def
|
|
169
|
-
|
|
225
|
+
def umbrella_header_path
|
|
226
|
+
File.join(project_root, "#{plugin_name}-umbrella.h")
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def modulemap_project_setting_path
|
|
230
|
+
"$(PROJECT_DIR)/#{File.basename(modulemap_path)}"
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def classes_root_path
|
|
234
|
+
File.join(project_root, 'Classes')
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def header_import_paths
|
|
238
|
+
Dir.glob(File.join(classes_root_path, '**', '*.h')).sort.filter_map do |header_path|
|
|
239
|
+
basename = File.basename(header_path)
|
|
240
|
+
next if basename == "#{plugin_name}-Bridging-Header.h"
|
|
241
|
+
|
|
242
|
+
basename
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def umbrella_header_contents
|
|
247
|
+
<<~HEADER
|
|
248
|
+
#ifdef __OBJC__
|
|
249
|
+
#import <UIKit/UIKit.h>
|
|
250
|
+
#else
|
|
251
|
+
#ifndef FOUNDATION_EXPORT
|
|
252
|
+
#if defined(__cplusplus)
|
|
253
|
+
#define FOUNDATION_EXPORT extern "C"
|
|
254
|
+
#else
|
|
255
|
+
#define FOUNDATION_EXPORT extern
|
|
256
|
+
#endif
|
|
257
|
+
#endif
|
|
258
|
+
#endif
|
|
259
|
+
|
|
260
|
+
#{header_import_paths.map { |path| %(#import "#{path}") }.join("\n")}
|
|
261
|
+
|
|
262
|
+
FOUNDATION_EXPORT double #{plugin_name}VersionNumber;
|
|
263
|
+
FOUNDATION_EXPORT const unsigned char #{plugin_name}VersionString[];
|
|
264
|
+
HEADER
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def modulemap_contents
|
|
268
|
+
<<~MODULEMAP
|
|
269
|
+
framework module #{plugin_name} {
|
|
270
|
+
umbrella header "#{File.basename(umbrella_header_path)}"
|
|
271
|
+
|
|
272
|
+
export *
|
|
273
|
+
module * { export * }
|
|
274
|
+
}
|
|
275
|
+
MODULEMAP
|
|
170
276
|
end
|
|
171
277
|
end
|
|
172
278
|
end
|
|
@@ -24,8 +24,11 @@ module GoNative
|
|
|
24
24
|
|
|
25
25
|
def call
|
|
26
26
|
assert_not_exists!
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
FileUtils.mkdir(plugin_name)
|
|
28
|
+
FileUtils.cd(plugin_name) do
|
|
29
|
+
cp_template_files!
|
|
30
|
+
Utils::TemplateInflator.new(plugin_name: plugin_name).call
|
|
31
|
+
end
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
def assert_not_exists!
|