cocoapods-binary-matchup 0.0.16 → 0.0.18

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: d82ba70bf3b96df6dbbe50edf16d8fec9c9272b6ccbde6c44a5daea0856fe32f
4
- data.tar.gz: 7319e7a787a703cb65bcd1254e551d2915a77d425145ab1c2fb09cbb44c6d90e
3
+ metadata.gz: 5ac1c4bb4db1b5e437ef1c6841de704d12e459b3f0e494af29d7f07421b6e33e
4
+ data.tar.gz: 6595cd815f89314d970ffdf1bfb8824b60b224c824b04d178643779984104ea3
5
5
  SHA512:
6
- metadata.gz: 3fe9edeed06572566c3da2b1e88614386dadbfbe23c511c2510896ffd5a267555f1173f319e85051368c7346586af30f7092de72409a6d8f19a52be01110e0e9
7
- data.tar.gz: f8f40c9dc1161621d12326662160fd56639ebeae1fcb8fb82d4a035c070a2c284b256a341935dacb396b0afdcc332628439cf05ea0d4a2184111b997a998eb85
6
+ metadata.gz: 80703fab252ab28abffb9b0932537add7c95e34d41ec042cc691e13224e4271d181a19dce9d0f88b75ff98fa832fafc32ad466234f17574f6dbd2d2e66c8c183
7
+ data.tar.gz: e5af0a07901d1a067e1e977a03daea4aecea122e7555c0516c82d1b733e3e7cd690890e14dd6c4ccdcf7005a2e95b7e2a87eac9102f95fc72b617f39895f7cba
data/README.md CHANGED
@@ -61,8 +61,6 @@ If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all
61
61
 
62
62
  if forbidden simulator, add a `simulator_build_disable!` before all targets in Podfile
63
63
 
64
- if custom main deployment target, add a `min_deployment_target(version)` before all targets in Podfile; e.g: `min_deployment_target(14.0)`
65
-
66
64
  if custom build configuration is needed, add a `set_custom_xcodebuild_options_for_prebuilt_frameworks` before all targets in Podfile; e.g:
67
65
  set_custom_xcodebuild_options_for_prebuilt_frameworks({
68
66
  :device => "ARCHS=arm64",
@@ -2,12 +2,17 @@ require 'fileutils'
2
2
  require 'digest'
3
3
 
4
4
  module Pod
5
+
6
+ class_attr_accessor :min_deployment_target
7
+
5
8
  module PrebuildCache
9
+
6
10
  class Cache
7
11
 
8
12
  # 获取缓存根目录
9
13
  def self.cache_root_dir
10
- cache_dir = File.expand_path("~/.PodCache/#{Pod::Podfile::DSL.min_deployment_target}")
14
+ cache_dir = File.expand_path("~/.PodCache/#{Pod.min_deployment_target}")
15
+ UI.puts "🔍 cache_root_dir #{cache_dir}"
11
16
  FileUtils.mkdir_p(cache_dir) unless Dir.exist?(cache_dir)
12
17
  cache_dir
13
18
  end
@@ -89,6 +94,7 @@ module Pod
89
94
 
90
95
  # 检查缓存是否存在
91
96
  def self.cache_exists?(pod_name, version)
97
+ Pod::UI.puts "🔍 cache_exists? #{pod_name} #{version}"
92
98
  cache_dir = cache_dir_for_pod(pod_name, version)
93
99
  Dir.exist?(cache_dir) && !Dir.empty?(cache_dir)
94
100
  end
@@ -30,9 +30,6 @@ module Pod
30
30
  DSL.dont_remove_source_code = true
31
31
  end
32
32
 
33
- def min_deployment_target(target)
34
- DSL.min_deployment_target = target
35
- end
36
33
 
37
34
  # Add custom xcodebuild option to the prebuilding action
38
35
  #
@@ -68,9 +65,6 @@ module Pod
68
65
  class_attr_accessor :simulator_build_enabled
69
66
  self.simulator_build_enabled = true
70
67
 
71
- class_attr_accessor :min_deployment_target
72
- self.min_deployment_target = '14.0'
73
-
74
68
  private
75
69
  class_attr_accessor :prebuild_all
76
70
  self.prebuild_all = false
@@ -106,6 +100,13 @@ Pod::HooksManager.register('cocoapods-binary-matchup', :pre_install) do |install
106
100
  exit
107
101
  end
108
102
  end
103
+
104
+ root_target = installer_context.podfile.target_definition_list.first
105
+ if root_target.platform
106
+ project_ios_version = root_target.platform.deployment_target
107
+ Pod::UI.puts "📱 Project iOS Version: #{project_ios_version.version}"
108
+ Pod.min_deployment_target = project_ios_version.version
109
+ end
109
110
 
110
111
 
111
112
  # -- step 1: prebuild framework ---
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBinary
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.18"
3
3
  end
@@ -20,23 +20,20 @@ def build_for_iosish_platform(sandbox,
20
20
  custom_build_options = [], # Array<String>
21
21
  custom_build_options_simulator = [] # Array<String>
22
22
  )
23
-
24
- deployment_target = Pod::Podfile::DSL.min_deployment_target
25
23
 
26
24
  target_label = target.label # name with platform if it's used in multiple platforms
27
25
  Pod::UI.puts "Prebuilding #{target_label}..."
28
- Pod::UI.puts "📦 deployment_target: #{deployment_target}"
29
26
 
30
27
  other_options = []
31
28
  # bitcode enabled
32
29
  other_options += ['BITCODE_GENERATION_MODE=bitcode'] if bitcode_enabled
33
30
 
34
- is_succeed, _ = xcodebuild(sandbox, target_label, device, deployment_target, other_options + custom_build_options)
31
+ is_succeed, _ = xcodebuild(sandbox, target_label, device, target, other_options + custom_build_options)
35
32
  exit 1 unless is_succeed
36
33
  if Pod::Podfile::DSL.simulator_build_enabled
37
34
  # make less arch to iphone simulator for faster build
38
35
  custom_build_options_simulator += ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'] if simulator == 'iphonesimulator'
39
- is_succeed, _ = xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + custom_build_options_simulator)
36
+ is_succeed, _ = xcodebuild(sandbox, target_label, simulator, target, other_options + custom_build_options_simulator)
40
37
  exit 1 unless is_succeed
41
38
  end
42
39
 
@@ -126,18 +123,111 @@ def build_for_iosish_platform(sandbox,
126
123
 
127
124
  # output
128
125
  output_path.mkpath unless output_path.exist?
126
+
127
+ # 🔑 添加资源处理 - 修复 iOS 14 资源丢失问题
128
+ copy_resources_to_framework(sandbox, target, device_framework_path)
129
+
129
130
  FileUtils.mv device_framework_path, output_path, :force => true
130
131
 
131
132
  end
132
133
 
134
+ # 新增函数:拷贝资源文件到 framework
135
+ def copy_resources_to_framework(sandbox, target, framework_path)
136
+ Pod::UI.puts "📋 Processing resources for #{target.name}..."
137
+
138
+ # 获取 target 的资源文件
139
+ pod_target = target
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)
142
+
143
+ # 1. 处理 resource_bundles(使用正确的 API)
144
+ resource_bundles = consumer.resource_bundles
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
154
+
155
+ # 2. 处理普通资源文件
156
+ unless file_accessor.resources.empty?
157
+ Pod::UI.puts " 📄 Processing #{file_accessor.resources.count} resource files"
158
+ file_accessor.resources.each do |resource_file|
159
+ if File.exist?(resource_file)
160
+ # 确定目标路径
161
+ relative_path = resource_file.relative_path_from(sandbox.pod_dir(pod_target.pod_name))
162
+ target_path = Pathname(framework_path) + relative_path.basename
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
170
+
171
+ # 3. 特别处理 Assets.xcassets (iOS 14 兼容性)
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
183
+
184
+ # 4. 处理 vendored_frameworks
185
+ unless file_accessor.vendored_frameworks.empty?
186
+ Pod::UI.puts " 🔗 Processing #{file_accessor.vendored_frameworks.count} vendored frameworks"
187
+ file_accessor.vendored_frameworks.each do |vendored_framework|
188
+ if File.exist?(vendored_framework)
189
+ framework_name = vendored_framework.basename
190
+ target_path = Pathname(framework_path).dirname + framework_name
191
+
192
+ FileUtils.cp_r(vendored_framework, target_path, :remove_destination => true)
193
+ Pod::UI.puts " 🔗 Copied vendored framework: #{framework_name}"
194
+ end
195
+ end
196
+ end
197
+
198
+ # 5. 处理 vendored_libraries
199
+ unless file_accessor.vendored_libraries.empty?
200
+ Pod::UI.puts " 📚 Processing #{file_accessor.vendored_libraries.count} vendored libraries"
201
+ file_accessor.vendored_libraries.each do |vendored_library|
202
+ if File.exist?(vendored_library)
203
+ library_name = vendored_library.basename
204
+ target_path = Pathname(framework_path) + library_name
205
+
206
+ FileUtils.cp_r(vendored_library, target_path, :remove_destination => true)
207
+ Pod::UI.puts " 📚 Copied vendored library: #{library_name}"
208
+ end
209
+ end
210
+ 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
+ end
226
+
133
227
  def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_options=[])
134
228
  args = %W(-project #{sandbox.project_path.realdirpath} -scheme #{target} -configuration #{CONFIGURATION} -sdk #{sdk} )
135
229
  platform = PLATFORMS[sdk]
136
- if !platform.nil?
137
- args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
138
- elsif
139
- args += ["IPHONEOS_DEPLOYMENT_TARGET=#{deployment_target}"]
140
- end
230
+ args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
141
231
  args += other_options
142
232
  Pod::UI.puts "📦 start compile project #{target} (#{args}) "
143
233
  log = `xcodebuild #{args.join(" ")} 2>&1`
data/spec/plugin_spec.rb CHANGED
@@ -22,7 +22,6 @@ describe "CocoaPods Binary Matchup Plugin" do
22
22
  dsl_methods.should.include?(:all_binary!)
23
23
  dsl_methods.should.include?(:enable_bitcode_for_prebuilt_frameworks!)
24
24
  dsl_methods.should.include?(:keep_source_code_for_prebuilt_frameworks!)
25
- dsl_methods.should.include?(:min_deployment_target)
26
25
  dsl_methods.should.include?(:simulator_build_disable!)
27
26
  dsl_methods.should.include?(:set_custom_xcodebuild_options_for_prebuilt_frameworks)
28
27
  end
@@ -30,18 +29,8 @@ describe "CocoaPods Binary Matchup Plugin" do
30
29
  it "should have correct default values for public attributes" do
31
30
  # 验证公开的默认配置值
32
31
  Pod::Podfile::DSL.simulator_build_enabled.should == true
33
- # should是bacon中的测试断言,这里的意思是min_deployment_target应该等于'14.0'
34
- Pod::Podfile::DSL.min_deployment_target.should == '14.0'
35
32
  end
36
33
 
37
- it "should allow setting min_deployment_target" do
38
- # 验证可以设置最小部署目标
39
- original_target = Pod::Podfile::DSL.min_deployment_target
40
- Pod::Podfile::DSL.min_deployment_target = '15.0'
41
- Pod::Podfile::DSL.min_deployment_target.should == '15.0'
42
- # 恢复原值
43
- Pod::Podfile::DSL.min_deployment_target = original_target
44
- end
45
34
 
46
35
  it "should allow toggling simulator build" do
47
36
  # 验证可以切换模拟器构建设置
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.16
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - leavez