cocoapods-binary-matchup 0.0.31 → 0.0.32

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: 77687afa8ff87355acd7b995f536a35aa4d1334d53d6ea7db4b6f86a02076ed9
4
- data.tar.gz: 0ceec41e504339e42451f6d4c917bffe08c3c586946a4b8fc6bdaf04b0e15d45
3
+ metadata.gz: f502abdc9c88f5bf6a8456317679006084ed07a542322c5dcd3a0c3d9626b672
4
+ data.tar.gz: 2c6885e69c0c152643fa3b6a219c449b4dc650de4f3d70acf584f1892c861df5
5
5
  SHA512:
6
- metadata.gz: c20a732d70ae30b3d58af05f1307153f0eba8aac9969d62b9480b6fafa797f988bec2d579789b138aaf4be086822000e9005c816803b21ce96d0ab931c897f21
7
- data.tar.gz: a2b128171275f2c3753940adc1bd2bd055be8ffadf2f7ee222c14b841e8e2407c1247a892c9e52970787306a5be7258a92be7d56b567526833d24a1fe38f461c
6
+ metadata.gz: e3998fdb496a4c3b63ff2ec2d122623c61b7054d720ad2a5beb17ec623019ee0cd009ee4654c560611d033845701fc89595dbe7a580aff100eb689f549d5eba2
7
+ data.tar.gz: 755c022f45768edddcce95be38afd9b816b4a1a83ff6bb101866159d419d0889d60bcea8712612efa949e767909288e582a9f175f63e692f27236619152a3414
data/Rakefile CHANGED
@@ -9,5 +9,18 @@ task :specs do
9
9
  sh "bundle exec bacon #{specs('**')}"
10
10
  end
11
11
 
12
+ desc 'Build gem and assert it is not empty (has lib/cocoapods_plugin.rb)'
13
+ task :build_and_verify do
14
+ require_relative 'lib/cocoapods-binary-matchup/gem_version'
15
+ gem_name = "cocoapods-binary-matchup-#{CocoapodsBinary::VERSION}.gem"
16
+ sh 'gem', 'build', 'cocoapods-binary-matchup.gemspec'
17
+ require 'rubygems/package'
18
+ files = Gem::Package.new(gem_name).spec.files
19
+ unless files.include?('lib/cocoapods_plugin.rb')
20
+ abort "[build_and_verify] #{gem_name} is empty/broken (files=#{files.size}). Abort push."
21
+ end
22
+ puts "[build_and_verify] OK: #{gem_name} contains #{files.size} files"
23
+ end
24
+
12
25
  task :default => :specs
13
26
 
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/omiapp/cocoapod_binary_matchup'
14
14
  spec.license = 'MIT'
15
15
 
16
- # 禁止用 git ls-files:本目录有嵌套 .git,ls-files 为空会打出空包(0.0.28/0.0.30 已踩坑)
16
+ # 禁止用 git ls-files:若本目录再出现空的嵌套 .git,ls-files 会为空从而打出空包(0.0.28/0.0.30
17
17
  spec.files = Dir.chdir(__dir__) do
18
18
  Dir.glob('{lib,spec}/**/*').reject { |f| File.directory?(f) } +
19
19
  Dir.glob('{LICENSE*,README*,*.gemspec,Gemfile,Rakefile}')
@@ -22,6 +22,14 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ['lib']
24
24
 
25
+ unless spec.files.include?('lib/cocoapods_plugin.rb')
26
+ raise <<~MSG
27
+ [cocoapods-binary-matchup] refuse to build an empty/broken gem:
28
+ spec.files is missing lib/cocoapods_plugin.rb (count=#{spec.files.size}).
29
+ Check gemspec file list; do not use `git ls-files` if a nested .git exists.
30
+ MSG
31
+ end
32
+
25
33
  spec.add_dependency "cocoapods", ">= 1.5.0", "< 2.0"
26
34
  spec.add_dependency "fourflusher", "~> 2.0"
27
35
  # CI 可能锁 xcpretty 0.3.x,过严会导致插件激活失败
@@ -137,8 +137,14 @@ module Pod
137
137
  standard_sandbox_path = sandbox.standard_sanbox_path
138
138
  Pod::UI.puts "📦 [#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] Prebuild Start pod: #{target.pod_name}"
139
139
  if Pod::PrebuildCache::Cache.restore_from_pod_cache(target.pod_name, sandbox)
140
- Pod::UI.puts "📦 [#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] Using exact cache from ~/.PodCache"
141
- next
140
+ output_path = sandbox.framework_folder_path_for_pod_name(target.name)
141
+ if prebuild_resource_bundles_missing?(target, output_path)
142
+ Pod::UI.puts "⚠️ Cached #{target.pod_name} missing resource_bundles; rebuilding..."
143
+ output_path.rmtree if output_path.exist?
144
+ else
145
+ Pod::UI.puts "📦 [#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] Using exact cache from ~/.PodCache"
146
+ next
147
+ end
142
148
  end
143
149
  Pod::UI.puts "📦 [#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] Prebuild End pod: #{target.pod_name}"
144
150
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBinary
2
- VERSION = "0.0.31"
2
+ VERSION = "0.0.32"
3
3
  end
@@ -131,6 +131,74 @@ def build_for_iosish_platform(sandbox,
131
131
 
132
132
  FileUtils.mv device_framework_path, output_path, :force => true
133
133
 
134
+ # resource_bundles(如 MatchUpSecurityWB.bundle)由 xcodebuild 生成在 products 目录,
135
+ # 原先只 mv 了 .framework,bundle 会随 build_dir 被删掉 → App 里找不到 m/m.bin。
136
+ # Integration 会把 resource_bundles 改成 resources: ["Xxx.bundle"],必须放在预编译产物根目录。
137
+ copy_resource_bundles_to_output(sandbox, target, output_path, build_dir, device)
138
+
139
+ end
140
+
141
+ # 把 podspec resource_bundles 产物拷到预编译输出目录(与 .framework 同级)
142
+ def copy_resource_bundles_to_output(sandbox, target, output_path, build_dir, device)
143
+ output_path = Pathname(output_path)
144
+ output_path.mkpath unless output_path.exist?
145
+
146
+ products_dir = Pathname("#{build_dir}/#{CONFIGURATION}-#{device}/#{target.name}")
147
+ copied = []
148
+
149
+ if products_dir.exist?
150
+ products_dir.children.select { |p| p.directory? && p.extname == '.bundle' }.each do |bundle|
151
+ dest = output_path + bundle.basename
152
+ FileUtils.rm_rf(dest) if dest.exist?
153
+ FileUtils.cp_r(bundle.to_s, dest.to_s)
154
+ copied << bundle.basename.to_s
155
+ Pod::UI.puts " 📦 Copied resource bundle from build products: #{bundle.basename}"
156
+ end
157
+ end
158
+
159
+ # 兜底:xcodebuild 未产出 bundle 时,按 file_accessor.resource_bundles 从源码组装
160
+ # (保留 Resources/ 之后的相对路径,如 m/m.bin)
161
+ expected_bundles = {}
162
+ Array(target.file_accessors).each do |fa|
163
+ next unless fa.respond_to?(:resource_bundles)
164
+ fa.resource_bundles.each do |name, paths|
165
+ expected_bundles[name] ||= []
166
+ expected_bundles[name].concat(Array(paths))
167
+ end
168
+ end
169
+
170
+ expected_bundles.each do |bundle_name, paths|
171
+ dest_bundle = output_path + "#{bundle_name}.bundle"
172
+ next if dest_bundle.exist? && copied.include?("#{bundle_name}.bundle")
173
+
174
+ Pod::UI.puts " 📦 Assembling resource bundle from sources: #{bundle_name}.bundle"
175
+ FileUtils.rm_rf(dest_bundle) if dest_bundle.exist?
176
+ dest_bundle.mkpath
177
+
178
+ pod_root = Pathname(sandbox.pod_dir(target.pod_name))
179
+ Array(paths).each do |path|
180
+ src = Pathname(path)
181
+ next unless src.file?
182
+
183
+ relative = resource_bundle_relative_path(src, pod_root)
184
+ dest = dest_bundle + relative
185
+ dest.dirname.mkpath unless dest.dirname.exist?
186
+ FileUtils.cp(src.to_s, dest.to_s)
187
+ Pod::UI.puts " 📄 #{relative}"
188
+ end
189
+ copied << "#{bundle_name}.bundle"
190
+ end
191
+
192
+ Pod::UI.puts " ✅ Resource bundles ready: #{copied.uniq.join(', ')}" unless copied.empty?
193
+ end
194
+
195
+ # Apps/Cocome/Resources/m/m.bin -> m/m.bin(与 CocoaPods resource_bundle 常见布局一致)
196
+ def resource_bundle_relative_path(file_path, pod_root)
197
+ rel_parts = Pathname(file_path).relative_path_from(Pathname(pod_root)).each_filename.to_a rescue [file_path.basename.to_s]
198
+ if (idx = rel_parts.index('Resources')) && idx < rel_parts.length - 1
199
+ return Pathname.new(rel_parts[(idx + 1)..-1].join('/'))
200
+ end
201
+ Pathname.new(file_path.basename)
134
202
  end
135
203
 
136
204
  # 新增函数:拷贝资源文件到 framework
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-binary-matchup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - leavez