cocoapods-binary-matchup 0.0.18 → 0.0.19
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07e6a14cf198cebbb76b6976937d49e9c898cc26587581455ead527556e3fa42
|
4
|
+
data.tar.gz: 52cde4cb69e7bf2ddccc15f96c16d79a702a9b5f294895161be96a562f255c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b393ac322ea327f09e914533d846693cc133653e1f0c8267131af131dbeeb52e53c6b8f1ae3ae128eb43ca463d9cde767edf453ca26faea5b785e5cb5ef61d19
|
7
|
+
data.tar.gz: 107faf52b261ee0ba0e73d4db661ed4a3d8677f395724b7af37675cc176ade72ff5736492608a61ee79bbfa58b97034082de0425dcdf04dd550adb7b6ab54368
|
@@ -172,8 +172,7 @@ Pod::HooksManager.register('cocoapods-binary-matchup', :pre_install) do |install
|
|
172
172
|
Pod::Podfile::DSL.enable_prebuild_patch false
|
173
173
|
Pod::Config.force_disable_write_lockfile false
|
174
174
|
Pod::Installer.disable_install_complete_message false
|
175
|
-
|
176
|
-
|
175
|
+
|
177
176
|
# -- step 2: pod install ---
|
178
177
|
# install
|
179
178
|
Pod::UI.puts "\n"
|
@@ -183,3 +182,211 @@ Pod::HooksManager.register('cocoapods-binary-matchup', :pre_install) do |install
|
|
183
182
|
# go on the normal install step ...
|
184
183
|
end
|
185
184
|
|
185
|
+
Pod::HooksManager.register('cocoapods-binary-matchup', :post_install) do |installer_context|
|
186
|
+
require_relative 'Integration'
|
187
|
+
|
188
|
+
# 检查是否是预构建阶段,如果是则跳过
|
189
|
+
require_relative 'helper/feature_switches'
|
190
|
+
if Pod.is_prebuild_stage
|
191
|
+
next
|
192
|
+
end
|
193
|
+
|
194
|
+
Pod::UI.puts "📱 Post-install: Adding prebuilt framework resources to Pods-OMI-resources.sh"
|
195
|
+
|
196
|
+
# 从ObjectSpace中获取installer实例(类似pre_install hook的做法)
|
197
|
+
installer = nil
|
198
|
+
include ObjectSpace
|
199
|
+
ObjectSpace.each_object(Pod::Installer) { |inst| installer = inst }
|
200
|
+
|
201
|
+
if installer.nil?
|
202
|
+
Pod::UI.puts "⚠️ Could not find installer instance, skipping framework resources processing"
|
203
|
+
next
|
204
|
+
end
|
205
|
+
|
206
|
+
# 处理每个aggregate target的资源脚本
|
207
|
+
installer.aggregate_targets.each do |aggregate_target|
|
208
|
+
if !aggregate_target.static_framework?
|
209
|
+
Pod::UI.puts " ⚠️ Skipping static framework: #{aggregate_target.name}"
|
210
|
+
next
|
211
|
+
end
|
212
|
+
|
213
|
+
# 手动构建资源脚本路径(CocoaPods没有直接的script_path API)
|
214
|
+
target_support_dir = installer.sandbox.target_support_files_dir(aggregate_target.name)
|
215
|
+
script_path = target_support_dir + "#{aggregate_target.name}-resources.sh"
|
216
|
+
|
217
|
+
Pod::UI.puts " 🔍 Checking script path: #{script_path}"
|
218
|
+
next unless script_path.exist?
|
219
|
+
|
220
|
+
Pod::UI.puts " 🔧 Processing #{script_path.basename}"
|
221
|
+
|
222
|
+
# 收集预编译framework的资源
|
223
|
+
framework_resources = collect_prebuilt_framework_resources(installer, aggregate_target)
|
224
|
+
|
225
|
+
if framework_resources.any?
|
226
|
+
# 修改资源脚本
|
227
|
+
modify_resources_script(script_path, framework_resources)
|
228
|
+
Pod::UI.puts " ✅ Added #{framework_resources.count} framework resources to #{script_path.basename}"
|
229
|
+
else
|
230
|
+
Pod::UI.puts " ℹ️ No framework resources found for #{aggregate_target.name}"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
Pod::UI.puts "✅ Framework resources processing completed"
|
235
|
+
end
|
236
|
+
|
237
|
+
# 收集预编译framework中的资源
|
238
|
+
def collect_prebuilt_framework_resources(installer, aggregate_target)
|
239
|
+
framework_resources = []
|
240
|
+
|
241
|
+
# 获取预编译的pod列表 - 强制刷新以确保获取最新状态
|
242
|
+
prebuilt_pod_names = installer.refresh_prebuild_pod_names!
|
243
|
+
|
244
|
+
aggregate_target.pod_targets.each do |pod_target|
|
245
|
+
next unless prebuilt_pod_names.include?(pod_target.pod_name)
|
246
|
+
|
247
|
+
Pod::UI.puts " 📱 Scanning prebuilt pod: #{pod_target.pod_name}"
|
248
|
+
|
249
|
+
# 获取pod目录
|
250
|
+
pod_dir = installer.sandbox.pod_dir(pod_target.pod_name)
|
251
|
+
next unless pod_dir.exist?
|
252
|
+
|
253
|
+
# 查找framework目录
|
254
|
+
framework_dirs = pod_dir.children.select { |child|
|
255
|
+
child.directory? && child.extname == '.framework'
|
256
|
+
}
|
257
|
+
|
258
|
+
framework_dirs.each do |framework_dir|
|
259
|
+
framework_name = framework_dir.basename.to_s
|
260
|
+
Pod::UI.puts " 🔍 Scanning framework: #{framework_name}"
|
261
|
+
|
262
|
+
# 扫描framework中的资源
|
263
|
+
resources = scan_framework_resources(framework_dir, pod_target.pod_name)
|
264
|
+
framework_resources.concat(resources)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
framework_resources.uniq
|
269
|
+
end
|
270
|
+
|
271
|
+
# 扫描framework中的资源文件
|
272
|
+
def scan_framework_resources(framework_dir, pod_name)
|
273
|
+
resources = []
|
274
|
+
framework_name = framework_dir.basename.to_s
|
275
|
+
|
276
|
+
Pod::UI.puts " 🎯 Framework path: #{framework_dir}"
|
277
|
+
Pod::UI.puts " 🎯 Pod name: #{pod_name}, Framework name: #{framework_name}"
|
278
|
+
|
279
|
+
# 资源文件类型
|
280
|
+
resource_patterns = [
|
281
|
+
'*.png', '*.jpg', '*.jpeg', '*.gif', '*.webp', # 图片
|
282
|
+
'*.storyboard', '*.xib', # 界面文件
|
283
|
+
'*.storyboardc', # 编译后的storyboard
|
284
|
+
'*.nib', # 编译后的xib
|
285
|
+
'*.bundle', # 资源包
|
286
|
+
'*.ttf', '*.otf', # 字体
|
287
|
+
'*.mp3', '*.wav', '*.m4a', '*.mp4', '*.mov' # 媒体
|
288
|
+
]
|
289
|
+
|
290
|
+
# 扫描framework根目录
|
291
|
+
resource_patterns.each do |pattern|
|
292
|
+
Dir.glob(framework_dir + pattern).each do |resource_path|
|
293
|
+
resource_file = Pathname(resource_path)
|
294
|
+
# 其他资源使用BUILT_PRODUCTS_DIR/framework路径
|
295
|
+
# 例如:${PODS_ROOT}/CocoaDebug/CocoaDebug.framework/App.storyboardc
|
296
|
+
resource_entry = "${PODS_ROOT}/#{pod_name}/#{framework_name}/#{resource_file.basename}"
|
297
|
+
resources << resource_entry
|
298
|
+
Pod::UI.puts " 📄 Found: #{resource_file.basename} -> #{resource_entry}"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
# 扫描framework/Resources目录
|
303
|
+
resources_dir = framework_dir + 'Resources'
|
304
|
+
if resources_dir.exist?
|
305
|
+
Pod::UI.puts " 📁 Scanning Resources subdirectory"
|
306
|
+
resource_patterns.each do |pattern|
|
307
|
+
Dir.glob(resources_dir + pattern).each do |resource_path|
|
308
|
+
resource_file = Pathname(resource_path)
|
309
|
+
|
310
|
+
# Resources目录中的资源也使用BUILT_PRODUCTS_DIR路径
|
311
|
+
resource_entry = "${PODS_ROOT}/#{pod_name}/#{framework_name}/#{resource_file.basename}"
|
312
|
+
resources << resource_entry
|
313
|
+
|
314
|
+
Pod::UI.puts " 📄 Found in Resources/: #{resource_file.basename} -> #{resource_entry}"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
Pod::UI.puts " 📊 Total resources found: #{resources.count}"
|
320
|
+
resources
|
321
|
+
end
|
322
|
+
|
323
|
+
# 修改resources脚本,添加framework资源
|
324
|
+
def modify_resources_script(script_path, framework_resources)
|
325
|
+
return if framework_resources.empty?
|
326
|
+
|
327
|
+
original_content = script_path.read
|
328
|
+
|
329
|
+
# 检查是否已经添加过framework资源(避免重复)
|
330
|
+
if original_content.include?('# Prebuilt Framework Resources')
|
331
|
+
Pod::UI.puts " ℹ️ Framework resources already added, skipping"
|
332
|
+
return
|
333
|
+
end
|
334
|
+
|
335
|
+
Pod::UI.puts " 📝 Adding #{framework_resources.count} framework resources to script"
|
336
|
+
framework_resources.each_with_index do |resource, index|
|
337
|
+
Pod::UI.puts " #{index + 1}. #{resource}"
|
338
|
+
end
|
339
|
+
|
340
|
+
# 构建要添加的资源安装代码
|
341
|
+
framework_resources_block = build_framework_resources_block(framework_resources)
|
342
|
+
|
343
|
+
# 在Debug配置块中插入framework资源(而不是脚本末尾)
|
344
|
+
debug_pattern = /if \[\[ "\$CONFIGURATION" == "Debug" \]\]; then/
|
345
|
+
if original_content.match(debug_pattern)
|
346
|
+
# 找到Debug配置块,在其中插入framework资源
|
347
|
+
modified_content = original_content.sub(debug_pattern) do |match|
|
348
|
+
"#{match}\n#{framework_resources_block}"
|
349
|
+
end
|
350
|
+
else
|
351
|
+
# 如果没有找到Debug配置块,创建一个新的
|
352
|
+
framework_resources_with_condition = <<~SCRIPT
|
353
|
+
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
354
|
+
#{framework_resources_block}
|
355
|
+
fi
|
356
|
+
SCRIPT
|
357
|
+
|
358
|
+
# 在脚本末尾(exit 0之前)插入
|
359
|
+
if original_content.include?('exit 0')
|
360
|
+
modified_content = original_content.sub(/exit 0/, "#{framework_resources_with_condition}\nexit 0")
|
361
|
+
else
|
362
|
+
modified_content = original_content + "\n#{framework_resources_with_condition}"
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
# 写回修改后的内容
|
367
|
+
script_path.write(modified_content)
|
368
|
+
|
369
|
+
Pod::UI.puts " ✅ Script modified successfully"
|
370
|
+
|
371
|
+
# 显示修改后脚本的相关部分以便验证
|
372
|
+
debug_lines = modified_content.lines.select.with_index do |line, index|
|
373
|
+
line.include?('CONFIGURATION') || line.include?('Prebuilt Framework') ||
|
374
|
+
(index > 0 && modified_content.lines[index-1].include?('CONFIGURATION'))
|
375
|
+
end
|
376
|
+
Pod::UI.puts " 📄 Debug configuration block preview:"
|
377
|
+
debug_lines.first(5).each { |line| Pod::UI.puts " #{line.chomp}" }
|
378
|
+
end
|
379
|
+
|
380
|
+
# 构建framework资源安装代码块
|
381
|
+
def build_framework_resources_block(framework_resources)
|
382
|
+
block = " # Prebuilt Framework Resources\n"
|
383
|
+
block += " echo \"Installing prebuilt framework resources...\"\n"
|
384
|
+
|
385
|
+
framework_resources.each do |resource|
|
386
|
+
block += " install_resource \"#{resource}\"\n"
|
387
|
+
end
|
388
|
+
|
389
|
+
block += " echo \"Prebuilt framework resources installation completed\"\n"
|
390
|
+
|
391
|
+
return block
|
392
|
+
end
|
@@ -124,8 +124,10 @@ def build_for_iosish_platform(sandbox,
|
|
124
124
|
# output
|
125
125
|
output_path.mkpath unless output_path.exist?
|
126
126
|
|
127
|
-
|
128
|
-
|
127
|
+
if target.static_framework?
|
128
|
+
# 🔑 添加资源处理 - 修复静态库资源丢失问题
|
129
|
+
copy_resources_to_framework(sandbox, target, device_framework_path)
|
130
|
+
end
|
129
131
|
|
130
132
|
FileUtils.mv device_framework_path, output_path, :force => true
|
131
133
|
|
@@ -135,93 +137,83 @@ end
|
|
135
137
|
def copy_resources_to_framework(sandbox, target, framework_path)
|
136
138
|
Pod::UI.puts "📋 Processing resources for #{target.name}..."
|
137
139
|
|
138
|
-
|
139
|
-
|
140
|
-
consumer = pod_target.root_spec.consumer(pod_target.platform.name)
|
141
|
-
file_accessor = Pod::Sandbox::FileAccessor.new(sandbox.pod_dir(pod_target.pod_name), consumer)
|
140
|
+
pod_dir = Pathname.new(sandbox.pod_dir(target.pod_name))
|
141
|
+
framework_dir = Pathname.new(framework_path)
|
142
142
|
|
143
|
-
#
|
144
|
-
|
145
|
-
unless resource_bundles.empty?
|
146
|
-
Pod::UI.puts " 📦 Processing #{resource_bundles.count} resource bundles"
|
147
|
-
resource_bundles.each do |bundle_name, bundle_files|
|
148
|
-
bundle_path = Pathname(framework_path).dirname + "#{bundle_name}.bundle"
|
149
|
-
if bundle_path.exist?
|
150
|
-
Pod::UI.puts " 📦 Found resource bundle: #{bundle_name}.bundle"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
143
|
+
# 直接递归扫描 pod 目录下的所有资源文件,拷贝到 framework 根目录
|
144
|
+
scan_and_copy_resources_flat(pod_dir, framework_dir)
|
154
145
|
|
155
|
-
#
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
# 拷贝资源文件
|
165
|
-
FileUtils.cp_r(resource_file, target_path, :remove_destination => true)
|
166
|
-
Pod::UI.puts " 📄 Copied resource: #{relative_path.basename}"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
146
|
+
Pod::UI.puts "✅ Resource processing completed for #{target.name}"
|
147
|
+
end
|
148
|
+
|
149
|
+
# 递归扫描资源文件并平铺拷贝到目标目录
|
150
|
+
def scan_and_copy_resources_flat(source_dir, target_dir)
|
151
|
+
# 确保参数是Pathname类型
|
152
|
+
source_dir = Pathname.new(source_dir) unless source_dir.is_a?(Pathname)
|
153
|
+
target_dir = Pathname.new(target_dir) unless target_dir.is_a?(Pathname)
|
170
154
|
|
171
|
-
|
172
|
-
assets_paths = file_accessor.resources.select { |path| path.extname == '.xcassets' }
|
173
|
-
unless assets_paths.empty?
|
174
|
-
Pod::UI.puts " 🎨 Processing #{assets_paths.count} Assets.xcassets for iOS 14 compatibility"
|
175
|
-
assets_paths.each do |assets_path|
|
176
|
-
relative_path = assets_path.relative_path_from(sandbox.pod_dir(pod_target.pod_name))
|
177
|
-
target_path = Pathname(framework_path) + relative_path.basename
|
178
|
-
|
179
|
-
FileUtils.cp_r(assets_path, target_path, :remove_destination => true)
|
180
|
-
Pod::UI.puts " 📱 Copied Assets.xcassets: #{relative_path.basename}"
|
181
|
-
end
|
182
|
-
end
|
155
|
+
Pod::UI.puts "📁 Recursively scanning directory: #{source_dir}"
|
183
156
|
|
184
|
-
#
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
Pod::UI.puts " 🔗 Copied vendored framework: #{framework_name}"
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
157
|
+
# 资源文件扩展名
|
158
|
+
resource_extensions = [
|
159
|
+
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', # 图片
|
160
|
+
'.storyboard', '.xib', '.storyboardc', '.nib', # 界面文件
|
161
|
+
'.ttf', '.otf', '.woff', '.woff2', # 字体
|
162
|
+
'.mp3', '.wav', '.m4a', '.mp4', '.mov', '.avi', # 媒体
|
163
|
+
'.json', '.plist', '.strings', '.xcassets', # 配置文件
|
164
|
+
'metallib' # metal or opengl文件
|
165
|
+
]
|
197
166
|
|
198
|
-
#
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
167
|
+
# 特殊处理的目录类型(这些需要完整保留)
|
168
|
+
special_directory_extensions = ['.bundle', '.xcassets', '.lproj']
|
169
|
+
|
170
|
+
# 递归查找并拷贝资源文件,传递原始根目录用于路径计算
|
171
|
+
find_and_copy_resources_recursively(source_dir, target_dir, source_dir, resource_extensions, special_directory_extensions)
|
172
|
+
end
|
173
|
+
|
174
|
+
# 递归查找资源文件并拷贝
|
175
|
+
def find_and_copy_resources_recursively(current_dir, target_dir, source_root_dir, resource_extensions, special_extensions)
|
176
|
+
# 确保所有参数都是Pathname类型
|
177
|
+
current_dir = Pathname.new(current_dir) unless current_dir.is_a?(Pathname)
|
178
|
+
target_dir = Pathname.new(target_dir) unless target_dir.is_a?(Pathname)
|
179
|
+
source_root_dir = Pathname.new(source_root_dir) unless source_root_dir.is_a?(Pathname)
|
180
|
+
|
181
|
+
return unless current_dir.exist? && current_dir.directory?
|
182
|
+
|
183
|
+
current_dir.children.each do |child|
|
184
|
+
# 跳过隐藏文件和系统目录
|
185
|
+
next if child.basename.to_s.start_with?('.')
|
186
|
+
next if ['.git', '.svn', 'node_modules', '.DS_Store'].include?(child.basename.to_s)
|
187
|
+
|
188
|
+
if child.directory?
|
189
|
+
# 检查是否是特殊资源目录(需要完整保留的)
|
190
|
+
if special_extensions.include?(child.extname)
|
191
|
+
Pod::UI.puts " 📦 Copying special directory: #{child.basename}"
|
192
|
+
target_path = target_dir + child.basename
|
193
|
+
FileUtils.cp_r(child.to_s, target_path.to_s, :remove_destination => true)
|
194
|
+
else
|
195
|
+
# 递归处理普通目录
|
196
|
+
find_and_copy_resources_recursively(child, target_dir, source_root_dir, resource_extensions, special_extensions)
|
197
|
+
end
|
198
|
+
else
|
199
|
+
# 检查是否是资源文件
|
200
|
+
if resource_extensions.include?(child.extname.downcase)
|
201
|
+
Pod::UI.puts " 📄 Copying resource file: #{child.basename}"
|
202
|
+
target_path = target_dir + child.basename
|
203
|
+
|
204
|
+
# 处理文件名冲突(如果有重名文件,添加路径前缀)
|
205
|
+
if target_path.exist?
|
206
|
+
# 计算相对于根目录的路径作为前缀
|
207
|
+
relative_dir = child.dirname.relative_path_from(source_root_dir)
|
208
|
+
safe_name = "#{relative_dir.to_s.gsub('/', '_')}_#{child.basename}"
|
209
|
+
target_path = target_dir + safe_name
|
210
|
+
Pod::UI.puts " ⚠️ File name conflict, renamed to: #{safe_name}"
|
211
|
+
end
|
205
212
|
|
206
|
-
FileUtils.
|
207
|
-
Pod::UI.puts " 📚 Copied vendored library: #{library_name}"
|
213
|
+
FileUtils.cp(child.to_s, target_path.to_s)
|
208
214
|
end
|
209
215
|
end
|
210
216
|
end
|
211
|
-
|
212
|
-
# 6. iOS 14 特别处理:确保资源目录结构正确
|
213
|
-
deployment_target = Pod.min_deployment_target
|
214
|
-
if deployment_target && Gem::Version.new(deployment_target) < Gem::Version.new("15.0")
|
215
|
-
Pod::UI.puts " 🔧 Applying iOS 14 compatibility fixes..."
|
216
|
-
|
217
|
-
# 确保 framework 内部有正确的目录结构
|
218
|
-
framework_resources_path = Pathname(framework_path) + "Resources"
|
219
|
-
framework_resources_path.mkpath unless framework_resources_path.exist?
|
220
|
-
|
221
|
-
Pod::UI.puts " ✅ iOS 14 compatibility applied"
|
222
|
-
end
|
223
|
-
|
224
|
-
Pod::UI.puts "✅ Resource processing completed for #{target.name}"
|
225
217
|
end
|
226
218
|
|
227
219
|
def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_options=[])
|
@@ -253,8 +245,6 @@ def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_optio
|
|
253
245
|
[is_succeed, log]
|
254
246
|
end
|
255
247
|
|
256
|
-
|
257
|
-
|
258
248
|
module Pod
|
259
249
|
class Prebuild
|
260
250
|
|