gonative-cli 2.1.3 → 2.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f7a146a01493fb4d9c5549b04f0d50e94da9162261d88100ee07490621512f2
4
- data.tar.gz: a6cdcb5036d748178bba4d3da3a850f175106ef2027f0d77ee28f74975f6f504
3
+ metadata.gz: 5711e0fe00d6ff54499bc81fd0fa237a7e98f1dc3ac64ef08a0e0b488524b2fb
4
+ data.tar.gz: 629786a400afa538d5259327d3ea971b1b497174f6e28318f2dc88687c7a0f8c
5
5
  SHA512:
6
- metadata.gz: 7f03a1a4580410fea17325183c3dacb694c1107f75ca44a2364e60597926506558430b0359e7a1f439b50eaba1617c377d884d5132cc2582ca5e1ec9c6f6f595
7
- data.tar.gz: 55f31f0dfaf30ecac9171c25b782329b241e9c34ffe58a902d38902304efdaa4cfd95486ff3e73bf3794f1af5dc2b5d9b0cb487203efe44304bf2fcba7fd27ed
6
+ metadata.gz: 31b03f07e20e077ea401b5e204080621609a4e29c137ae7a271f2890dfb44e8a8a7e3109167d2ff8192d3747464f82d04f2ae397cecb0daa8ff4536adc1f0f9c
7
+ data.tar.gz: 9751fae3c5b84b04b9c2f25d85f2d5ff097fcaec4f97ced4ef31072f229f3a65091e0f4f9c28c48f1724b9abd8a23d18d16effa55e36cbaf85366ab4365ae443
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'cocoapods'
4
4
  require 'shellwords'
5
+ require 'tmpdir'
5
6
  require 'pathname'
6
7
  require 'xcodeproj'
7
8
 
@@ -105,6 +106,7 @@ module GoNative
105
106
  def patch_build_settings!(config)
106
107
  config.build_settings.delete('SWIFT_OBJC_BRIDGING_HEADER')
107
108
  config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
109
+ config.build_settings['STRIP_INSTALLED_PRODUCT'] = 'NO' if config.build_settings['MACH_O_TYPE'] == 'staticlib'
108
110
  config.build_settings['MODULEMAP_FILE'] = modulemap_project_setting_path
109
111
  end
110
112
 
@@ -122,9 +124,15 @@ module GoNative
122
124
  FileUtils.rm_rf(simulator_archive_path)
123
125
  FileUtils.rm_rf(device_archive_path)
124
126
 
125
- return if system(archive_commands)
127
+ if system(archive_commands)
128
+ [simulator_framework_path, device_framework_path].each { |path| prune_dependency_objects!(path) }
129
+ return if system(create_xcframework_command)
130
+ end
126
131
 
127
132
  raise Error, 'Error building framework with Tuist. Please run the generated archive commands manually to inspect the failure'
133
+ ensure
134
+ FileUtils.rm_rf(simulator_archive_path)
135
+ FileUtils.rm_rf(device_archive_path)
128
136
  end
129
137
 
130
138
  def archive_commands
@@ -139,14 +147,65 @@ module GoNative
139
147
  destination: "generic/platform=iOS",
140
148
  archive_path: device_archive_path,
141
149
  sdk: "iphoneos"
142
- ),
143
- create_xcframework_command,
144
- %(rm -rf #{Shellwords.escape(simulator_archive_path)} #{Shellwords.escape(device_archive_path)})
150
+ )
145
151
  ].join(' && ')
146
152
  end
147
153
 
154
+ # Removes package product objects from a static framework archive, keeping the plugin's own.
155
+ def prune_dependency_objects!(framework_path)
156
+ binary = File.join(framework_path, plugin_name)
157
+ return unless `file -b #{Shellwords.escape(binary)}`.include?('ar archive')
158
+
159
+ archs = `lipo -archs #{Shellwords.escape(binary)}`.split
160
+ Dir.mktmpdir do |dir|
161
+ slices = archs.map do |arch|
162
+ slice = File.join(dir, "#{arch}.a")
163
+ if archs.size > 1
164
+ system("lipo #{Shellwords.escape(binary)} -thin #{arch} -output #{Shellwords.escape(slice)}") or
165
+ raise Error, "Failed to extract #{arch} from #{binary}"
166
+ else
167
+ FileUtils.cp(binary, slice)
168
+ end
169
+
170
+ dependency_objects = `ar -t #{Shellwords.escape(slice)}`.split("\n").reject { |member| plugin_object?(member) }
171
+ unless dependency_objects.empty?
172
+ Utils::UI.info "Removing #{dependency_objects.size} dependency objects from #{arch} slice"
173
+ system("ar -d #{Shellwords.escape(slice)} #{dependency_objects.map { |m| Shellwords.escape(m) }.join(' ')}") &&
174
+ system("ranlib #{Shellwords.escape(slice)}") or
175
+ raise Error, "Failed to prune #{arch} slice of #{binary}"
176
+ end
177
+ slice
178
+ end
179
+
180
+ if slices.size > 1
181
+ system("lipo -create #{slices.map { |s| Shellwords.escape(s) }.join(' ')} -output #{Shellwords.escape(binary)}") or
182
+ raise Error, "Failed to recombine #{binary}"
183
+ else
184
+ FileUtils.cp(slices.first, binary)
185
+ end
186
+ end
187
+ end
188
+
189
+ def plugin_object?(member)
190
+ return true if member.start_with?('__.SYMDEF') || member.start_with?(plugin_name)
191
+
192
+ plugin_source_stems.any? { |stem| member == "#{stem}.o" || member.start_with?("#{stem}-") }
193
+ end
194
+
195
+ def plugin_source_stems
196
+ @plugin_source_stems ||= Dir.glob(File.join(classes_root_path, '**', '*.{swift,m,mm,c,cpp}'))
197
+ .map { |path| File.basename(path, '.*') }
198
+ .uniq
199
+ end
200
+
201
+ # Static frameworks produce no dSYM.
148
202
  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)})
203
+ slices = [[simulator_framework_path, simulator_dsym_path], [device_framework_path, device_dsym_path]]
204
+ arguments = slices.map do |framework, dsym|
205
+ argument = "-framework #{Shellwords.escape(framework)}"
206
+ File.exist?(dsym) ? "#{argument} -debug-symbols #{Shellwords.escape(dsym)}" : argument
207
+ end
208
+ %(xcodebuild -create-xcframework #{arguments.join(' ')} -output #{Shellwords.escape(xcframework_output_path)})
150
209
  end
151
210
 
152
211
  def xcodebuild_archive_command(destination:, archive_path:, sdk:, archs_override: false)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoNative
4
- VERSION = '2.1.3'
4
+ VERSION = '2.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gonative-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hunaid Hassan