gonative-cli 2.1.2 → 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: 073e0214b6ad0ada956f93e770130ee06608c61793a59c54a11c5722b5ca71be
4
- data.tar.gz: 6c38a76729e16b26c75d27313bf447914e1ddc4e0f026c447d85b1baa2e1e501
3
+ metadata.gz: 5711e0fe00d6ff54499bc81fd0fa237a7e98f1dc3ac64ef08a0e0b488524b2fb
4
+ data.tar.gz: 629786a400afa538d5259327d3ea971b1b497174f6e28318f2dc88687c7a0f8c
5
5
  SHA512:
6
- metadata.gz: 2815121dab597534abcd5ea731307debd50191f14e331a5a24125453e590d6c9dbd933e3eb5699b0be3ba1eabf173de7d020fe606c2f6a53a81bc66ecf4b8e85
7
- data.tar.gz: f6abe9f73f0d6cbe32c21f0788e9b6efe7625f97c77f39a29ac1fd3d7619103666d20d1e6339a74e16bb7aac0249d8dc44f7747f88d4f39cfb7792f26896327f
6
+ metadata.gz: 31b03f07e20e077ea401b5e204080621609a4e29c137ae7a271f2890dfb44e8a8a7e3109167d2ff8192d3747464f82d04f2ae397cecb0daa8ff4536adc1f0f9c
7
+ data.tar.gz: 9751fae3c5b84b04b9c2f25d85f2d5ff097fcaec4f97ced4ef31072f229f3a65091e0f4f9c28c48f1724b9abd8a23d18d16effa55e36cbaf85366ab4365ae443
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gonative-cli (2.1.2)
4
+ gonative-cli (2.1.1)
5
5
  activesupport (~> 6.0)
6
6
  aws-sdk-s3 (~> 1)
7
7
  cocoapods (~> 1.10)
@@ -100,6 +100,7 @@ GEM
100
100
  ffi (>= 1.15.0)
101
101
  logger
102
102
  ffi (1.17.4-arm64-darwin)
103
+ ffi (1.17.4-x86_64-darwin)
103
104
  fourflusher (2.3.1)
104
105
  fuzzy_match (2.0.4)
105
106
  gh_inspector (1.1.3)
@@ -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)
@@ -75,8 +75,6 @@ module GoNative
75
75
 
76
76
  unless name.end_with?('Plugin')
77
77
  Utils::UI.info "Skipping #{File.basename(xcframework_path)} (dependency)"
78
- # Strip any stale signature: Xcode hard-fails on an invalid seal,
79
- # but accepts unsigned binary targets.
80
78
  system "codesign --remove-signature #{Shellwords.escape(xcframework_path)} 2>/dev/null"
81
79
  next
82
80
  end
@@ -159,9 +157,7 @@ module GoNative
159
157
 
160
158
  FileUtils.rm_f(temp_zip)
161
159
 
162
- # Create zip from Frameworks/ directory.
163
- # -y stores symlinks as symlinks: macOS/Catalyst framework slices use
164
- # Versions/A symlink layouts, and materializing them breaks codesign seals.
160
+ # Create zip from Frameworks/ directory
165
161
  FileUtils.cd(frameworks_dir) do
166
162
  system "zip -Xqry #{Shellwords.escape(temp_zip)} #{Shellwords.escape("#{name}.xcframework")}" or
167
163
  raise Error, "Failed to zip #{name}.xcframework"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoNative
4
- VERSION = '2.1.2'
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.2
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hunaid Hassan