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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +33 -21
  3. data/lib/gonative/commands/ios/build.rb +19 -0
  4. data/lib/gonative/commands/ios/publish.rb +20 -5
  5. data/lib/gonative/commands/ios/version.rb +3 -5
  6. data/lib/gonative/commands.rb +1 -0
  7. data/lib/gonative/plugins/ios/build_framework.rb +223 -117
  8. data/lib/gonative/plugins/ios/create.rb +5 -2
  9. data/lib/gonative/plugins/ios/release.rb +162 -24
  10. data/lib/gonative/plugins/ios/verify.rb +1 -7
  11. data/lib/gonative/plugins/ios/version.rb +8 -8
  12. data/lib/gonative/utils/template_inflator.rb +8 -4
  13. data/lib/gonative/utils.rb +1 -1
  14. data/lib/gonative/version.rb +1 -1
  15. data/templates/plugins/android/plugin-metadata.json.erb +7 -0
  16. data/templates/plugins/android/src/main/{AndroidManifest.xml.tpl → AndroidManifest.xml.erb} +2 -2
  17. data/templates/plugins/android/src/main/java/io/gonative/android/plugins/JAVA_PACKAGE/{PLUGIN_NAME.java.tpl → PLUGIN_NAME.java.erb} +3 -3
  18. data/templates/plugins/ios/common/Package.swift.erb +28 -0
  19. data/templates/plugins/ios/common/Project.swift.erb +44 -0
  20. data/templates/plugins/ios/common/Resources/polyfill.js.erb +10 -0
  21. data/templates/plugins/ios/common/VERSION +1 -0
  22. data/templates/plugins/ios/common/Wrappers/dummy.m +1 -0
  23. data/templates/plugins/ios/common/Wrappers/include/dummy.h +1 -0
  24. data/templates/plugins/ios/language-specific/objc/{PLUGIN_NAME/Classes/GNPLUGIN_NAME.h.tpl → Classes/GNPLUGIN_NAME.h.erb} +4 -4
  25. data/templates/plugins/ios/language-specific/objc/Classes/GNPLUGIN_NAME.m.erb +14 -0
  26. data/templates/plugins/ios/language-specific/objc/Project.swift.erb +44 -0
  27. data/templates/plugins/ios/language-specific/swift/Classes/GNSwiftModule.m.erb +12 -0
  28. data/templates/plugins/ios/language-specific/swift/Classes/GNSwiftModule.swift.erb +14 -0
  29. data/templates/plugins/ios/language-specific/swift/Project.swift.erb +43 -0
  30. metadata +22 -25
  31. data/lib/gonative/utils/content_evaluator.rb +0 -16
  32. data/templates/build/ios/Info.plist +0 -28
  33. data/templates/build/ios/PLUGIN_NAME-umbrella.h.tpl +0 -16
  34. data/templates/build/ios/PLUGIN_NAME.modulemap.tpl +0 -6
  35. data/templates/build/ios/Podfile.tpl +0 -10
  36. data/templates/build/ios/create-framework.sh.tpl +0 -36
  37. data/templates/plugins/android/plugin-metadata.json.tpl +0 -7
  38. data/templates/plugins/ios/common/PLUGIN_NAME/Classes/Dummy.swift +0 -6
  39. data/templates/plugins/ios/common/PLUGIN_NAME/Resources/polyfill.js.tpl +0 -0
  40. data/templates/plugins/ios/common/PLUGIN_NAME.podspec.tpl +0 -30
  41. data/templates/plugins/ios/language-specific/objc/PLUGIN_NAME/Classes/GNPLUGIN_NAME.m.tpl +0 -14
  42. data/templates/plugins/ios/language-specific/swift/PLUGIN_NAME/Classes/GNSwiftModule.m.tpl +0 -12
  43. data/templates/plugins/ios/language-specific/swift/PLUGIN_NAME/Classes/GNSwiftModule.swift.tpl +0 -14
  44. /data/templates/plugins/ios/common/{PLUGIN_NAME/Frameworks → Frameworks}/.keep +0 -0
  45. /data/templates/plugins/ios/common/{PLUGIN_NAME/Info.plist → Info.plist} +0 -0
  46. /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: 9fd3e16aa80e616a08e2147bd78206d961a233543ed0631d9aab97626a9a3bc8
4
- data.tar.gz: 6e573e449b23effca005802f1344aaa3815c37dee6f1b460e8d46339d6b9680d
3
+ metadata.gz: 35dc9f759236d6b1ac5b65b11b0bb90577d288cc1b160298762adab4d782ccba
4
+ data.tar.gz: 4db543701fb3d94aaec48058e789ef111264dd5ce2cbba27af8e6a02f5a779e5
5
5
  SHA512:
6
- metadata.gz: 61949fbb4482552258e9ff94781a2cdc01882a2d24282f7e99d24a4d01ee2e53db558b6d6df6679563f4151f737e57c54b3221c8149c9f87a6bf8b8dee699363
7
- data.tar.gz: 2702d5787c740d1eb5af9137710e0797fb677542a9830f1b0da179573169a9ef481d7f000a1d845998440698076bcd3f6a8654585b29e7498babae2302998d5f
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 (1.5.6)
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.5)
18
- rexml
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.3.0)
33
- aws-partitions (1.1014.0)
34
- aws-sdk-core (3.214.0)
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
- aws-sdk-kms (1.96.0)
40
- aws-sdk-core (~> 3, >= 3.210.0)
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.174.0)
43
- aws-sdk-core (~> 3, >= 3.210.0)
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.10.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.15.0)
99
+ ethon (0.18.0)
95
100
  ffi (>= 1.15.0)
96
- ffi (1.15.5)
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.8.3)
101
- i18n (1.14.6)
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.7.2)
111
+ json (2.19.3)
112
+ logger (1.7.0)
105
113
  method_source (1.0.0)
106
- minitest (5.25.1)
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.0)
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.23.0)
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.6.18)
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 :podspec, required: true, desc: 'Podspec name'
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(podspec:, skip_build:, debug:, archs:, **)
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(podspec, archs, debug) unless skip_build
18
- Plugins::IOS::Release.call(podspec)
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 of a Podspec file'
7
+ desc 'Get version from VERSION file'
8
8
 
9
- argument :podspec, required: true, desc: 'Podspec name'
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
@@ -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
- BUILD_TEMPLATE_DIRECTORY_PATH = File.expand_path(File.join(__dir__, '../../../..', 'templates', 'build', 'ios'))
16
+ attr_reader :archs, :persist_build_dir, :project_root
17
17
 
18
- attr_reader :plugin_name, :archs, :persist_build_dir
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
- created_build_dir = cd_build_dir
30
- setup_build_dir if created_build_dir
31
- build_framework!
32
- move_framework_file
33
- zip!
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
- FileUtils.rm_rf('build') unless persist_build_dir
38
- end
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 add_classes(target, group)
77
- classes_group = group.new_group('Classes', 'Classes')
78
- references = Dir.glob("../#{plugin_name}/Classes/**/*.{m,swift}").map do |file|
79
- classes_group.new_file("../../#{file}")
80
- end
81
- target.add_file_references(references)
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 add_frameworks(target, group)
85
- frameworks_group = group.new_group('Frameworks', 'Frameworks')
86
- references = Dir.glob("../#{plugin_name}/Frameworks/*.{framework,xcframework}").map do |file|
87
- frameworks_group.new_file("../../#{file}")
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
- return unless references.length
72
+ end
90
73
 
91
- references.each { |ref| target.frameworks_build_phase.add_file_reference(ref) }
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 add_headers(target, group)
95
- headers_group = group.new_group('Headers', 'Headers')
96
- references = Dir.glob("../#{plugin_name}/Classes/**/*.h").map do |file|
97
- headers_group.new_file("../../#{file}")
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
- header_files = target.add_file_references(references)
100
- header_files << target.headers_build_phase.add_file_reference(group.new_file("../#{plugin_name}-umbrella.h"))
101
- header_files.each do |header|
102
- header.settings = { 'ATTRIBUTES' => ['Public'] }
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 move_template_files!
107
- plugin_dependencies = spec.dependencies.map do |d|
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 run_pod_install
120
- system 'pod install'
181
+ def simulator_archive_path
182
+ File.join('.build', 'Frameworks', 'simulator.xcarchive')
121
183
  end
122
184
 
123
- def chmod_frameworks_script!
124
- FileUtils.chmod 0755, 'create-framework.sh'
185
+ def device_archive_path
186
+ File.join('.build', 'Frameworks', 'iOS.xcarchive')
125
187
  end
126
188
 
127
- def build_framework!
128
- Utils::UI.info 'Building framework'
129
- return if system('sh create-framework.sh >/dev/null 2>/dev/null')
189
+ def xcframework_output_path
190
+ File.join('.build', 'Frameworks', "#{plugin_name}.xcframework")
191
+ end
130
192
 
131
- raise Error, 'Error building framework. Please run the create-framework file manually to fix any errors'
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 move_framework_file
135
- FileUtils.mv("Frameworks/#{plugin_name}.xcframework", "../#{plugin_name}/Frameworks")
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 zip!
139
- FileUtils.cd('..')
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 zip_file_name
147
- "#{plugin_name}-v#{spec.version}.zip"
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 upload_to_s3
151
- s3 = Aws::S3::Client.new(
152
- region: ENV['S3_REGION'],
153
- access_key_id: ENV['ACCESS_KEY_ID'],
154
- secret_access_key: ENV['SECRET_ACCESS_KEY']
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
- s3.put_object(
158
- bucket: ENV['S3_BUCKET'],
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 deployment_target
165
- spec.deployment_target('ios') || '15.5'
221
+ def modulemap_path
222
+ File.join(project_root, "#{plugin_name}.modulemap")
166
223
  end
167
224
 
168
- def spec
169
- @spec ||= Pod::Specification.from_file("../#{plugin_name}.podspec")
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
- cp_template_files!
28
- Utils::TemplateInflator.new(plugin_name: plugin_name).call
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!