gonative-cli 1.5.7 → 2.0.1

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +33 -21
  3. data/lib/gonative/commands/ios/build.rb +3 -4
  4. data/lib/gonative/commands/ios/publish.rb +20 -5
  5. data/lib/gonative/commands/ios/version.rb +3 -5
  6. data/lib/gonative/plugins/ios/build_framework.rb +240 -91
  7. data/lib/gonative/plugins/ios/create.rb +5 -2
  8. data/lib/gonative/plugins/ios/release.rb +144 -49
  9. data/lib/gonative/plugins/ios/verify.rb +1 -7
  10. data/lib/gonative/plugins/ios/version.rb +8 -8
  11. data/lib/gonative/utils/template_inflator.rb +8 -4
  12. data/lib/gonative/utils.rb +1 -1
  13. data/lib/gonative/version.rb +1 -1
  14. data/templates/plugins/android/plugin-metadata.json.erb +7 -0
  15. data/templates/plugins/android/src/main/{AndroidManifest.xml.tpl → AndroidManifest.xml.erb} +2 -2
  16. data/templates/plugins/android/src/main/java/io/gonative/android/plugins/JAVA_PACKAGE/{PLUGIN_NAME.java.tpl → PLUGIN_NAME.java.erb} +3 -3
  17. data/templates/plugins/ios/common/Package.swift.erb +28 -0
  18. data/templates/plugins/ios/common/Project.swift.erb +44 -0
  19. data/templates/plugins/ios/common/Resources/polyfill.js.erb +10 -0
  20. data/templates/plugins/ios/common/VERSION +1 -0
  21. data/templates/plugins/ios/common/Wrappers/dummy.m +1 -0
  22. data/templates/plugins/ios/common/Wrappers/include/dummy.h +1 -0
  23. data/templates/plugins/ios/language-specific/objc/{PLUGIN_NAME/Classes/GNPLUGIN_NAME.h.tpl → Classes/GNPLUGIN_NAME.h.erb} +4 -4
  24. data/templates/plugins/ios/language-specific/objc/Classes/GNPLUGIN_NAME.m.erb +14 -0
  25. data/templates/plugins/ios/language-specific/objc/Project.swift.erb +44 -0
  26. data/templates/plugins/ios/language-specific/swift/Classes/GNSwiftModule.m.erb +12 -0
  27. data/templates/plugins/ios/language-specific/swift/Classes/GNSwiftModule.swift.erb +14 -0
  28. data/templates/plugins/ios/language-specific/swift/Project.swift.erb +43 -0
  29. metadata +19 -20
  30. data/lib/gonative/utils/content_evaluator.rb +0 -16
  31. data/templates/build/ios/Info.plist +0 -28
  32. data/templates/build/ios/PLUGIN_NAME-umbrella.h.tpl +0 -16
  33. data/templates/build/ios/PLUGIN_NAME.modulemap.tpl +0 -6
  34. data/templates/build/ios/Podfile.tpl +0 -10
  35. data/templates/build/ios/create-framework.sh.tpl +0 -36
  36. data/templates/plugins/android/plugin-metadata.json.tpl +0 -7
  37. data/templates/plugins/ios/common/PLUGIN_NAME/Classes/Dummy.swift +0 -6
  38. data/templates/plugins/ios/common/PLUGIN_NAME/Resources/polyfill.js.tpl +0 -0
  39. data/templates/plugins/ios/common/PLUGIN_NAME.podspec.tpl +0 -30
  40. data/templates/plugins/ios/language-specific/objc/PLUGIN_NAME/Classes/GNPLUGIN_NAME.m.tpl +0 -14
  41. data/templates/plugins/ios/language-specific/swift/PLUGIN_NAME/Classes/GNSwiftModule.m.tpl +0 -12
  42. data/templates/plugins/ios/language-specific/swift/PLUGIN_NAME/Classes/GNSwiftModule.swift.tpl +0 -14
  43. /data/templates/plugins/ios/common/{PLUGIN_NAME/Frameworks → Frameworks}/.keep +0 -0
  44. /data/templates/plugins/ios/common/{PLUGIN_NAME/Info.plist → Info.plist} +0 -0
  45. /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: 2ccd449bdbd09a555a2f2fcd1de8684d89504b692cafcad2a01d9e84f1532ad7
4
- data.tar.gz: bf7d46201af803a17fd2a749da1cb8d26288807d77b68d432d639d5f1d9a6965
3
+ metadata.gz: c1b59414d5bf06c920d0487fd63e0d450abd19bafcc56729a7b37de393ad853d
4
+ data.tar.gz: b84779d9fc8bc938dc6a0fed226b7a92b8987ca5d4b353aa842389298f476f13
5
5
  SHA512:
6
- metadata.gz: aadc0d51c984464e1fc3422b1c13a9ba625ff9ec8af88531beabddcfa767b1b3a8b2f73f9159a7c308dd6bda403cfa0494616bb51435897588931711758f1fae
7
- data.tar.gz: 547160cc66fe329a2d1362bc4ff64dbd5dbbc6f3ad58f6d8994301d4d8b637d99cf49048889b7bc359c34a75b30abe8ecdc79abd18d3ada4c7f5b1ae72382763
6
+ metadata.gz: 4e5c03aa2191569d84f077852599fff88be4a5903d97e3abf911e22d322d7a6355e153cf3c90b424a9d5c08883fe96db21d7ab5bc682ebed5b196512c2dc8483
7
+ data.tar.gz: b9ffe744b3666c45f42249c6df921a88218a746bb0d092aa7f217f0d2d6ec79de5df38303fcd054e0a16ee5972f4e45d93830bee7c057112d1e0c30e308d5341
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
@@ -6,15 +6,14 @@ module GoNative
6
6
  class Build < Base
7
7
  desc 'Build a framework without releasing'
8
8
 
9
- argument :podspec, required: true, desc: 'Podspec name'
10
9
  option :debug, type: :boolean, default: false, desc: 'Keep build directory for debugging'
11
10
  option :archs, default: 'x86_64,arm64', desc: 'Comma-separated list of architectures to build'
12
11
 
13
- def call(podspec:, debug:, archs:, **)
12
+ def call(debug:, archs:, **)
14
13
  Plugins::IOS::Verify.call
15
- Plugins::IOS::BuildFramework.call(podspec, archs, debug)
14
+ Plugins::IOS::BuildFramework.call(archs, debug)
16
15
  end
17
16
  end
18
17
  end
19
18
  end
20
- 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
@@ -1,8 +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
7
 
7
8
  module GoNative
8
9
  module Plugins
@@ -12,127 +13,275 @@ module GoNative
12
13
 
13
14
  extend DSL::Serviceable
14
15
 
15
- BUILD_TEMPLATE_DIRECTORY_PATH = File.expand_path(File.join(__dir__, '../../../..', 'templates', 'build', 'ios'))
16
+ attr_reader :archs, :persist_build_dir, :project_root
16
17
 
17
- attr_reader :plugin_name, :archs, :persist_build_dir
18
-
19
- def initialize(podspec, archs, persist_build_dir)
20
- raise Error, 'No podspec exists.' unless File.exist?(podspec)
21
-
22
- @plugin_name = File.basename(podspec, '.podspec')
18
+ def initialize(archs, persist_build_dir, project_root = FileUtils.pwd)
23
19
  @archs = archs.gsub(',', ' ')
24
20
  @persist_build_dir = persist_build_dir
21
+ @project_root = File.expand_path(project_root)
25
22
  end
26
23
 
27
24
  def call
28
- created_build_dir = cd_build_dir
29
- setup_build_dir if created_build_dir
30
- build_framework!
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!
31
30
  ensure
32
- FileUtils.cd('..')
33
- FileUtils.rm_rf('build') unless persist_build_dir
34
- end
35
-
36
- def cd_build_dir
37
- build_dir = File.join(FileUtils.pwd, 'build')
38
- return false if File.exist?(build_dir)
39
-
40
- FileUtils.mkdir(build_dir)
41
- FileUtils.cd(build_dir)
42
- true
43
- end
44
-
45
- def setup_build_dir
46
- create_framework_proj
47
- move_template_files!
48
- run_pod_install
49
- chmod_frameworks_script!
50
- end
51
-
52
- def create_framework_proj
53
- proj = Xcodeproj::Project.new(FileUtils.pwd)
54
- target = proj.new_target(:framework,
55
- plugin_name.to_s,
56
- :ios,
57
- deployment_target)
58
- main_group = proj.new_group(plugin_name, plugin_name)
59
- add_classes(target, main_group)
60
- add_frameworks(target, main_group)
61
- add_headers(target, main_group)
62
- target.build_configurations.each do |config|
63
- config.build_settings['INFOPLIST_FILE'] = 'Info.plist'
64
- config.build_settings['MARKETING_VERSION'] = spec.version
65
- config.build_settings['MODULEMAP_FILE'] = "#{plugin_name}.modulemap"
66
- config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = "org.cocoapods.#{plugin_name}"
67
- config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'
68
- end
69
- 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
+
34
+ end
35
+
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!
70
44
  end
71
45
 
72
- def add_classes(target, group)
73
- classes_group = group.new_group('Classes', 'Classes')
74
- references = Dir.glob("../#{plugin_name}/Classes/**/*.{m,swift}").map do |file|
75
- classes_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]
76
71
  end
77
- target.add_file_references(references)
78
72
  end
79
73
 
80
- def add_frameworks(target, group)
81
- frameworks_group = group.new_group('Frameworks', 'Frameworks')
82
- references = Dir.glob("../#{plugin_name}/Frameworks/*.{framework,xcframework}").map do |file|
83
- frameworks_group.new_file("../../#{file}")
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)
78
+ end
79
+
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)
84
93
  end
85
- return unless references.length
86
94
 
87
- references.each { |ref| target.frameworks_build_phase.add_file_reference(ref) }
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(' && ')
88
146
  end
89
147
 
90
- def add_headers(target, group)
91
- headers_group = group.new_group('Headers', 'Headers')
92
- references = Dir.glob("../#{plugin_name}/Classes/**/*.h").map do |file|
93
- headers_group.new_file("../../#{file}")
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)}"
94
162
  end
95
- header_files = target.add_file_references(references)
96
- header_files << target.headers_build_phase.add_file_reference(group.new_file("../#{plugin_name}-umbrella.h"))
97
- header_files.each do |header|
98
- header.settings = { 'ATTRIBUTES' => ['Public'] }
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 << "MARKETING_VERSION=#{Shellwords.escape(marketing_version)}" if marketing_version
175
+
176
+ command.join(" ")
177
+ end
178
+
179
+ def marketing_version
180
+ @marketing_version ||= begin
181
+ version_file = File.join(project_root, 'VERSION')
182
+ File.read(version_file).strip if File.exist?(version_file)
99
183
  end
100
184
  end
101
185
 
102
- def move_template_files!
103
- plugin_dependencies = spec.dependencies.map do |d|
104
- ["pod '#{d.name}'", "'#{d.requirement}'"].compact.join(', ')
105
- end * "\n\t"
106
- FileUtils.cp_r("#{BUILD_TEMPLATE_DIRECTORY_PATH}/.", '.')
107
- headers = Dir.glob("../#{plugin_name}/Classes/**/*.h").map { |f| "#import \"#{File.basename(f)}\"" } * "\n"
108
- Utils::TemplateInflator.new(plugin_name: plugin_name,
109
- plugin_dependencies: plugin_dependencies,
110
- plugin_headers: headers,
111
- archs: archs,
112
- deployment_target: deployment_target).call
186
+ def tuist_workspace_path
187
+ "#{plugin_name}.xcworkspace"
188
+ end
189
+
190
+ def simulator_archive_path
191
+ File.join('.build', 'Frameworks', 'simulator.xcarchive')
192
+ end
193
+
194
+ def device_archive_path
195
+ File.join('.build', 'Frameworks', 'iOS.xcarchive')
196
+ end
197
+
198
+ def xcframework_output_path
199
+ File.join('.build', 'Frameworks', "#{plugin_name}.xcframework")
200
+ end
201
+
202
+ def simulator_framework_path
203
+ File.expand_path(File.join(simulator_archive_path, 'Products', 'Library', 'Frameworks', "#{plugin_name}.framework"), project_root)
204
+ end
205
+
206
+ def device_framework_path
207
+ File.expand_path(File.join(device_archive_path, 'Products', 'Library', 'Frameworks', "#{plugin_name}.framework"), project_root)
113
208
  end
114
209
 
115
- def run_pod_install
116
- system 'pod install'
210
+ def simulator_dsym_path
211
+ File.expand_path(File.join(simulator_archive_path, 'dSYMs', "#{plugin_name}.framework.dSYM"), project_root)
117
212
  end
118
213
 
119
- def chmod_frameworks_script!
120
- FileUtils.chmod 0755, 'create-framework.sh'
214
+ def device_dsym_path
215
+ File.expand_path(File.join(device_archive_path, 'dSYMs', "#{plugin_name}.framework.dSYM"), project_root)
121
216
  end
122
217
 
123
- def build_framework!
124
- Utils::UI.info 'Building framework'
125
- return if system('sh create-framework.sh >/dev/null 2>/dev/null')
218
+ def cleanup_build_dir
219
+ FileUtils.rm_rf(File.join(project_root, '.build'))
220
+ FileUtils.rm_rf(File.join(project_root, "#{plugin_name}.xcodeproj"))
221
+ FileUtils.rm_rf(File.join(project_root, "#{plugin_name}.xcworkspace"))
222
+ FileUtils.rm_f(File.join(project_root, "#{plugin_name}.modulemap"))
223
+ FileUtils.rm_f(File.join(project_root, "#{plugin_name}-umbrella.h"))
224
+ end
126
225
 
127
- raise Error, 'Error building framework. Please run the create-framework file manually to fix any errors'
226
+ def xcodeproj_path
227
+ File.join(project_root, "#{plugin_name}.xcodeproj")
128
228
  end
129
229
 
130
- def deployment_target
131
- spec.deployment_target('ios') || '15.5'
230
+ def modulemap_path
231
+ File.join(project_root, "#{plugin_name}.modulemap")
132
232
  end
133
233
 
134
- def spec
135
- @spec ||= Pod::Specification.from_file("../#{plugin_name}.podspec")
234
+ def umbrella_header_path
235
+ File.join(project_root, "#{plugin_name}-umbrella.h")
236
+ end
237
+
238
+ def modulemap_project_setting_path
239
+ "$(PROJECT_DIR)/#{File.basename(modulemap_path)}"
240
+ end
241
+
242
+ def classes_root_path
243
+ File.join(project_root, 'Classes')
244
+ end
245
+
246
+ def header_import_paths
247
+ Dir.glob(File.join(classes_root_path, '**', '*.h')).sort.filter_map do |header_path|
248
+ basename = File.basename(header_path)
249
+ next if basename == "#{plugin_name}-Bridging-Header.h"
250
+
251
+ basename
252
+ end
253
+ end
254
+
255
+ def umbrella_header_contents
256
+ <<~HEADER
257
+ #ifdef __OBJC__
258
+ #import <UIKit/UIKit.h>
259
+ #else
260
+ #ifndef FOUNDATION_EXPORT
261
+ #if defined(__cplusplus)
262
+ #define FOUNDATION_EXPORT extern "C"
263
+ #else
264
+ #define FOUNDATION_EXPORT extern
265
+ #endif
266
+ #endif
267
+ #endif
268
+
269
+ #{header_import_paths.map { |path| %(#import "#{path}") }.join("\n")}
270
+
271
+ FOUNDATION_EXPORT double #{plugin_name}VersionNumber;
272
+ FOUNDATION_EXPORT const unsigned char #{plugin_name}VersionString[];
273
+ HEADER
274
+ end
275
+
276
+ def modulemap_contents
277
+ <<~MODULEMAP
278
+ framework module #{plugin_name} {
279
+ umbrella header "#{File.basename(umbrella_header_path)}"
280
+
281
+ export *
282
+ module * { export * }
283
+ }
284
+ MODULEMAP
136
285
  end
137
286
  end
138
287
  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!