cocoapods-dongjia 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5b4528303fd0cec1f74fc6cf438693b70f6fb791ff0f4f02cabd5d7a74fa461
4
- data.tar.gz: 50a77d0e54c9a2ebdad88a59c8a58f9d06ba35f924852ffec73d867679eb35f8
3
+ metadata.gz: dca107525ae9be1b7ed4f8bd40b5247cbcc5258035b9a0cc33ad4e4a96def6f3
4
+ data.tar.gz: c0d15ab36c6ad63daf5c82cffd1cbd8d41fc30d3a5ba1c1ddab2e3a468d2a36d
5
5
  SHA512:
6
- metadata.gz: f203e960ce068e3e3a6a852ae8614faae63d481b50c458743b4be8ebeb4b033f76b2c36c51ee0766f8e4a97cce40fb94603cccbd42327e21f76b07c66474f8f2
7
- data.tar.gz: 38da2b3d06573fb9f582f3725b45c77926432fa0e2c67240f8f7667200ed34c8d17b1bfd8ee074ff4c5783cb4462dd12c7c53c87e3ab3054bcc725a8dfea21c5
6
+ metadata.gz: 43b4aa9ab668b94cfca481ab715c5de4f338f4ba22bfdc13c2c0cdbd673ed69aac48668fbe794f56c4a2babed20e527fc5e3c246ec485436b070b3dce02290f2
7
+ data.tar.gz: 364c8b20c8dd4c8c1e1255abeaf69049f57c656bb6690cbaea4153278a108d8f84d892505d63c21048cfedac2f55fae29c8fcc775f50c1d32829d67165ea1d55
@@ -18,7 +18,14 @@ module Pod
18
18
  CLAide::Argument.new('XCODE_PROJECT', false),
19
19
  ]
20
20
 
21
+ def self.options
22
+ [
23
+ ["--save", "将重新生成的 project.pbxproj 文件保存下来"]
24
+ ]
25
+ end
26
+
21
27
  def initialize(argv)
28
+ @save = argv.flag?("save")
22
29
  path = argv.shift_argument
23
30
  @project_path = Pathname.new(path) if path
24
31
  super
@@ -45,7 +52,7 @@ module Pod
45
52
 
46
53
  deintegrator = Deintegrator.new
47
54
  deintegrator.deintegrate_project(@project)
48
- @project.save
55
+ @project.save if @save
49
56
 
50
57
  verify_podfile_exists!
51
58
  installer = installer_for_config
@@ -1,6 +1,7 @@
1
1
  module CocoapodsDongjia
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  UPDATE_DESC = <<-EOS
4
- - 优化 post_install 行为,避免 install 后导致全量编译
4
+ - 支持集成二进制版本的 Pod
5
+ - 优化 reinstall 命令
5
6
  EOS
6
7
  end
@@ -4,17 +4,21 @@ require_relative 'dongjia_branch_inspector'
4
4
  require_relative 'dongjia_enterprise_inspector'
5
5
  require_relative 'dongjia_pods_iterator'
6
6
  require_relative 'dongjia_router'
7
- require_relative 'dongjia_scheme_manager'
7
+ require_relative 'dongjia_binarization'
8
8
 
9
9
  require_relative 'helper/podfile'
10
10
  require_relative 'helper/podfile_options'
11
- require_relative 'helper/podfile_warnings'
11
+ require_relative 'helper/installer'
12
12
  require_relative 'helper/Core/podfile/dsl'
13
13
 
14
14
  module Dongjia
15
15
 
16
16
  Pod::HooksManager.register('cocoapods-dongjia', :pre_install) do |ctx, params|
17
17
 
18
+ Binarization.load_private_config(ctx)
19
+
20
+ Binarization.remove_dirty_pod_projects()
21
+
18
22
  podfile = ctx.podfile
19
23
 
20
24
  # 禁用集成完后的反馈
@@ -25,7 +29,6 @@ module Dongjia
25
29
 
26
30
  # 关闭静态框架依赖传递的校验
27
31
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
28
-
29
32
  end
30
33
 
31
34
  Pod::HooksManager.register('cocoapods-dongjia', :post_install) do |ctx, params|
@@ -33,13 +36,8 @@ module Dongjia
33
36
  # 关闭警告 / 检查 LTO
34
37
  PodsIterator.iterate(params, ctx.sandbox_root)
35
38
 
36
- # 处理 appspec 配置
37
- # SchemeManager.setup(ctx, params)
38
-
39
39
  # 抓取所有路由汇总至
40
- router = Router.new
41
- router.scrape_routers(ctx.sandbox_root, params[:scrap_routers])
42
-
40
+ # router = Router.new
41
+ # router.scrape_routers(ctx.sandbox_root, params[:scrap_routers])
43
42
  end
44
-
45
43
  end
@@ -0,0 +1,577 @@
1
+ require 'xcodeproj'
2
+ require 'fileutils'
3
+ require 'archive/zip'
4
+ require 'net/http'
5
+ require 'json'
6
+ require 'yaml'
7
+ require 'down'
8
+ require 'pry'
9
+ require 'uri'
10
+
11
+ module Dongjia
12
+ class Binarization
13
+
14
+ @@ctx = nil
15
+ @@pod_cfg = {}
16
+ @@enabled = false
17
+ @@target_name = ""
18
+ @@submodules = {}
19
+ @@server_host = ""
20
+
21
+ # 配置文件 PrivateConfig.yml 是否存在,如果不存在,不做任何额外处理
22
+ @@config_file_exist = false
23
+
24
+ class << self
25
+ # 加载配置
26
+ def load_private_config(ctx)
27
+ @@ctx = ctx
28
+
29
+ submodule_info = load_submodules_info
30
+ @@submodules = submodule_info.to_h { |s|
31
+ [
32
+ s[:name],
33
+ { sha: s[:sha], binary: s[:binary], }
34
+ ]
35
+ }
36
+
37
+ path = ctx.podfile.defined_in_file.dirname.join("PrivateConfig.yml")
38
+ if path.exist?
39
+ config = YAML.load(File.read(path))
40
+ @@config_file_exist = true
41
+ if config
42
+ binary = config["binary"]
43
+ if binary
44
+ @@enabled ||= binary["enabled"]
45
+ @@server_host = binary["server_host"]
46
+ @@target_name = binary["target_name"].strip
47
+ ignores = binary["ignores"] || []
48
+
49
+ begin
50
+ @@submodules = query_components_existing(submodule_info).to_h { |s|
51
+ [
52
+ s["name"],
53
+ { sha: s["sha"], binary: s["binary"], }
54
+ ]
55
+ }.each { |k, v|
56
+ ignored = ignores.include?(k)
57
+ v[:binary] &&= !ignored && @@enabled
58
+ v[:ignored] = ignored
59
+ }
60
+ rescue => e
61
+ puts "Error: #{e}"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ # 移除脏工程
69
+ def remove_dirty_pod_projects
70
+ @@submodules
71
+ .filter { |k,v| !v[:binary] }
72
+ .map { |k,v| k }
73
+ .each { |name|
74
+ path = "./Pods/#{name}.xcodeproj"
75
+ next unless File.exist?(path)
76
+ proj = Xcodeproj::Project.open(path)
77
+ if proj.targets.map(&:name).include?("#{name}-Binary")
78
+ FileUtils.rm_rf(path)
79
+ end
80
+ }
81
+ end
82
+
83
+ # 加载子模块信息
84
+ def load_submodules_info
85
+ # 获取子模块的哈希值
86
+ def git_sha_value(component_name)
87
+ git_dir = ".git/modules/componentsOnRemote/#{component_name}"
88
+ git_sha = File.read(File.join(git_dir, "HEAD")).strip
89
+ if git_sha.start_with?("ref: ")
90
+ head_file = git_sha[5, git_sha.length]
91
+ git_sha = File.read(File.join(git_dir, head_file)).strip
92
+ end
93
+ git_sha
94
+ end
95
+
96
+ Dir.foreach("./componentsOnRemote").to_a
97
+ .delete_if { |x| x.start_with?('.') }
98
+ .map { |comp|
99
+ {
100
+ name: comp,
101
+ sha: git_sha_value(comp),
102
+ binary: false,
103
+ }
104
+ }
105
+ end
106
+
107
+ # 开始处理二进制
108
+ def process(installer)
109
+ return unless @@config_file_exist
110
+ return if @@ctx == nil || @@ctx.sandbox_root == nil
111
+
112
+ installer.analysis_result.podfile_dependency_cache.podfile_dependencies.each { |dep|
113
+ name = dep.name.split('/').first
114
+ next if @@pod_cfg.include?(name)
115
+ @@pod_cfg[name] = @@submodules[name] || {
116
+ binary: false
117
+ }
118
+ }
119
+
120
+ pods_proj = Xcodeproj::Project.open(File.join(@@ctx.sandbox_root, "Pods.xcodeproj"))
121
+ if @@target_name && !@@target_name.empty?
122
+ pods_target = pods_proj.targets.find { |t| t.name == "Pods-#{@@target_name}" }
123
+ else
124
+ pods_target = pods_proj.targets.first
125
+ end
126
+
127
+ download_frameworks
128
+
129
+ each_pod_proj do |name|
130
+ proj = Xcodeproj::Project.open(File.join(@@ctx.sandbox_root, "#{name}.xcodeproj"))
131
+ cfg = @@pod_cfg[name]
132
+ cfg[:project] = proj
133
+
134
+ cfg[:save] = process_target_and_dependencies(proj, name, pods_target, cfg)
135
+
136
+ # 处理 Binary Group
137
+ process_binary_group(proj, name)
138
+
139
+ # 处理 XXX-xcframeworks.sh 脚本
140
+ process_xcframeworks_shell(name)
141
+
142
+ process_pod_xcconfig(name)
143
+ end
144
+
145
+ # 更新依赖关系
146
+ each_pod_proj do |name|
147
+ cfg = @@pod_cfg[name]
148
+ proj = cfg[:project]
149
+ target = cfg[:target]
150
+ next if target.nil?
151
+ delete_list = []
152
+ target.dependencies.each { |dep|
153
+ dep_cfg = @@pod_cfg[dep.name]
154
+ next if dep_cfg.nil?
155
+ if dep_cfg[:binary]
156
+ target.add_dependency(dep_cfg[:target])
157
+ delete_list << dep
158
+ end
159
+ }
160
+ target.dependencies.delete_if { |dep| delete_list.include?(dep) }
161
+ cfg[:save] ||= !delete_list.empty?
162
+ end
163
+
164
+ # 保存
165
+ should_save = false
166
+ each_pod_proj do |name|
167
+ cfg = @@pod_cfg[name]
168
+ cfg[:project].save if cfg[:save]
169
+ should_save ||= cfg[:save]
170
+ end
171
+ pods_proj.save if should_save
172
+
173
+ process_aggregate_target_xcconfig(installer.aggregate_targets.first.name)
174
+ end
175
+
176
+ private
177
+
178
+ # 遍历 Pods 目录下的 xcodeproj
179
+ def each_pod_proj
180
+ Dir.foreach(@@ctx.sandbox_root) do |filename|
181
+ next if File.extname(filename) != '.xcodeproj'
182
+
183
+ name = File.basename(filename, '.xcodeproj')
184
+ next if name == 'Pods'
185
+
186
+ cfg = @@pod_cfg[name]
187
+
188
+ yield(name) if block_given?
189
+ end
190
+ end
191
+
192
+ # 向服务器查询哪些 Pod 需要打包
193
+ def query_components_existing(components)
194
+ result = components
195
+ begin
196
+ uri = URI.parse(URI::join(@@server_host, 'api/binary/checkup').to_s)
197
+ headers = {
198
+ 'Content-Type': 'application/json'
199
+ }
200
+ req = Net::HTTP::Post.new(uri, headers)
201
+ req.body = {components: components}.to_json
202
+ resp = Net::HTTP.start(uri.host, uri.port) do |http|
203
+ http.request(req)
204
+ end
205
+ result = JSON.parse(resp.body).dig('res', 'components')
206
+ rescue => e
207
+ puts "Error: #{e}"
208
+ end
209
+ return result
210
+ end
211
+
212
+ def process_target_and_dependencies(proj, name, pods_target, cfg)
213
+ changed = false
214
+ source_target = proj.target_by_name(name)
215
+ binary_target = proj.target_by_name("#{name}-Binary")
216
+
217
+ if cfg[:binary] == true
218
+ # 使用 Binary 版本的 target
219
+ if binary_target == nil
220
+ binary_target = add_binary_target(proj, name)
221
+ changed = true
222
+ end
223
+
224
+ @@pod_cfg[name][:target] = binary_target
225
+
226
+ # 移除源码版本的 target
227
+ if source_target
228
+ replace_target_dependency(pods_target, source_target, binary_target)
229
+ proj.targets.delete_if { |t| t == source_target }
230
+ changed = true
231
+ end
232
+ else
233
+ @@pod_cfg[name][:target] = source_target
234
+ # 使用源码版本的 target
235
+ source_target.build_configurations.each { |cfg|
236
+ if cfg.build_settings["BUILD_LIBRARY_FOR_DISTRIBUTION"] != "YES"
237
+ cfg.build_settings["BUILD_LIBRARY_FOR_DISTRIBUTION"] = "YES"
238
+ changed = true
239
+ end
240
+ }
241
+ end
242
+ changed
243
+ end
244
+
245
+ # 处理对应 pod 的 xcconfig
246
+ def process_pod_xcconfig(name)
247
+ # 根据 pod 是源码还是二进制包,切换路径为 PODS_CONFIGURATION_BUILD_DIR 或 PODS_XCFRAMEWORKS_BUILD_DIR
248
+ ["debug", "release"].each { |cfg_name|
249
+ cfg_path = Pathname("./Pods/Target Support Files/#{name}/#{name}.#{cfg_name}.xcconfig")
250
+ next if not File.exist?(cfg_path)
251
+ cfg = Xcodeproj::Config.new(cfg_path)
252
+ fsp_str = cfg.attributes["FRAMEWORK_SEARCH_PATHS"] || "$(inherited)"
253
+ fsp = fsp_str.split(" ")
254
+
255
+ # 源码的 prefix
256
+ source_prefix = "\"${PODS_CONFIGURATION_BUILD_DIR}/"
257
+ # 二进制包的 prefix
258
+ binary_prefix = "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/"
259
+
260
+ fsp.map! { |path|
261
+ if path.start_with?(source_prefix)
262
+ pod_name = path[source_prefix.length, path.length].delete_suffix("\"")
263
+ sm = @@submodules[pod_name]
264
+ if !sm.nil? && sm[:binary]
265
+ path = path.gsub("PODS_CONFIGURATION_BUILD_DIR", "PODS_XCFRAMEWORKS_BUILD_DIR")
266
+ end
267
+ elsif path.start_with?(binary_prefix)
268
+ pod_name = path[binary_prefix.length, path.length].delete_suffix("\"")
269
+ sm = @@submodules[pod_name]
270
+ if !sm.nil? && !sm[:binary]
271
+ path = path.gsub("PODS_XCFRAMEWORKS_BUILD_DIR", "PODS_CONFIGURATION_BUILD_DIR")
272
+ end
273
+ end
274
+ path
275
+ }
276
+ cfg.attributes["FRAMEWORK_SEARCH_PATHS"] = fsp.flatten.uniq.join(" ")
277
+ cfg.save_as(cfg_path)
278
+ }
279
+ end
280
+
281
+ # 处理集成对象的 xcconfig(项目的 xcconfig)
282
+ def process_aggregate_target_xcconfig(aggregate_target_name)
283
+ # 处理 Pods/Target Support Files/Pods-项目名/Pods-项目名.debug(release).xcconfig
284
+ # 所有被二进制化的 pod,增加 "${PODS_XCFRAMEWORKS_BUILD_DIR}/#{pod_name}"
285
+ ["debug", "release"].each { |cfg_name|
286
+ cfg_path = Pathname("./Pods/Target Support Files/#{aggregate_target_name}/#{aggregate_target_name}.#{cfg_name}.xcconfig")
287
+ next if not File.exist?(cfg_path)
288
+ cfg = Xcodeproj::Config.new(cfg_path)
289
+ fsp = cfg.attributes["FRAMEWORK_SEARCH_PATHS"].split(" ") || ["$(inherited)"]
290
+ @@submodules.each { |k, v|
291
+ path = "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/#{k}\""
292
+ if v[:binary] == true
293
+ fsp << path if not fsp.include?(path)
294
+ else
295
+ fsp.delete_if { |x| x == path }
296
+ end
297
+ }
298
+ cfg.attributes["FRAMEWORK_SEARCH_PATHS"] = fsp.flatten.uniq.join(" ")
299
+ cfg.save_as(cfg_path)
300
+ }
301
+ end
302
+
303
+ def add_binary_target(proj, name)
304
+ source_target = proj.target_by_name(name)
305
+ bin_target = proj.new_aggregate_target("#{name}-Binary", [], :ios, '10.0')
306
+
307
+ # 处理 xcconfig 引用
308
+ cfg_list0 = source_target.build_configuration_list
309
+ cfg_list1 = bin_target.build_configuration_list
310
+ cfg_list1["Debug"].base_configuration_reference ||= cfg_list0["Debug"].base_configuration_reference
311
+ cfg_list1["Release"].base_configuration_reference ||= cfg_list0["Release"].base_configuration_reference
312
+
313
+ # 处理 Build Phases
314
+ phase = bin_target.new_shell_script_build_phase("[CP] Copy XCFrameworks")
315
+ phase.shell_script = "\"${PODS_ROOT}/Target Support Files/#{name}/#{name}-xcframeworks.sh\""
316
+
317
+ # 添加依赖
318
+ bin_target.dependencies.replace(source_target.dependencies)
319
+ return bin_target
320
+ end
321
+
322
+ def replace_target_dependency(target, from_dep_target, to_dep_target)
323
+ dep_names = target.dependencies.map(&:name)
324
+ index = dep_names.index(from_dep_target.name)
325
+ return false if !index
326
+ target.dependencies.delete_at(index)
327
+ target.add_dependency(to_dep_target)
328
+ return true
329
+ end
330
+
331
+ # 下载 framework 到 Pods/_Frameworks 目录下
332
+ def download_frameworks
333
+ framework_root = File.join(@@ctx.sandbox_root, "_Frameworks")
334
+ cache_root = File.join(framework_root, "Caches")
335
+ FileUtils.mkdir_p(cache_root) unless File.exist?(cache_root)
336
+
337
+ @@submodules.each { |k, v|
338
+ if !v[:binary] || !v[:sha]
339
+ puts "#{k} 未发现二进制版本" if @@enabled && !v[:ignored]
340
+ next
341
+ end
342
+
343
+ module_cache_dir = File.join(cache_root, k)
344
+ FileUtils.mkdir_p(module_cache_dir) unless File.exist?(module_cache_dir)
345
+
346
+ filename = "#{v[:sha]}.zip"
347
+ binary_dir = File.join(module_cache_dir, v[:sha])
348
+ if not File.exist?(binary_dir)
349
+ # 目录不存在,下载 zip 包并解压
350
+ binary_zip_path = File.join(module_cache_dir, filename)
351
+ puts "Downloading #{k} (#{v[:sha]})"
352
+ url = URI::join(@@server_host, "binary/#{k}/#{filename}")
353
+ Down.download(url, destination: binary_zip_path)
354
+ Archive::Zip.extract(binary_zip_path, binary_dir)
355
+ FileUtils.rm_f(binary_zip_path)
356
+ end
357
+ target = File.expand_path(File.join(binary_dir, "#{k}.xcframework"))
358
+ FileUtils.ln_s(target, framework_root, force: true)
359
+ }
360
+ end
361
+
362
+ def process_binary_group(proj, name)
363
+ cfg = @@pod_cfg[name]
364
+ binary_group = proj.groups.find { |g| g.name == "Binary" }
365
+ if cfg[:binary] == true
366
+ if binary_group == nil
367
+ binary_group = proj.new_group("Binary")
368
+ binary_group.new_reference("_Frameworks/#{name}.xcframework")
369
+ proj.sort
370
+ end
371
+ else
372
+ if binary_group != nil
373
+ binary_group.remove_from_project
374
+ end
375
+ end
376
+ end
377
+
378
+ def process_xcframeworks_shell(name)
379
+ cfg = @@pod_cfg[name]
380
+ return if cfg[:binary] != true
381
+ script_path = File.join(@@ctx.sandbox_root, "Target Support Files", name, "#{name}-xcframeworks.sh")
382
+ File.open(script_path, 'w') do |f|
383
+ f.write(xcframeworks_shell(name))
384
+ end
385
+ FileUtils.chmod('a+x', script_path)
386
+ end
387
+
388
+ # 获取当前 Wi-Fi 的 SSID
389
+ def get_wifi_ssid
390
+ lines = `/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I`.split("\n").map { |line| line.strip }
391
+ target = lines.find { |x| x.start_with?("SSID: ") }
392
+ target.nil? ? "" : target.delete_prefix("SSID: ")
393
+ end
394
+ end
395
+ end
396
+ end
397
+
398
+ module Dongjia
399
+ class Binarization
400
+ def self.xcframeworks_shell(pod_name)
401
+ <<-DESC
402
+ #!/bin/sh
403
+ set -e
404
+ set -u
405
+ set -o pipefail
406
+
407
+ function on_error {
408
+ echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
409
+ }
410
+ trap 'on_error $LINENO' ERR
411
+
412
+
413
+ # This protects against multiple targets copying the same framework dependency at the same time. The solution
414
+ # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
415
+ RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
416
+
417
+
418
+ copy_dir()
419
+ {
420
+ local source="$1"
421
+ local destination="$2"
422
+
423
+ # Use filter instead of exclude so missing patterns don't throw errors.
424
+ echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}\\" \\"${destination}\\""
425
+ rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}" "${destination}"
426
+ }
427
+
428
+ SELECT_SLICE_RETVAL=""
429
+
430
+ select_slice() {
431
+ local paths=("$@")
432
+ # Locate the correct slice of the .xcframework for the current architectures
433
+ local target_path=""
434
+
435
+ # Split archs on space so we can find a slice that has all the needed archs
436
+ local target_archs=$(echo $ARCHS | tr " " "\\n")
437
+
438
+ local target_variant=""
439
+ if [[ "$PLATFORM_NAME" == *"simulator" ]]; then
440
+ target_variant="simulator"
441
+ fi
442
+ if [[ ! -z ${EFFECTIVE_PLATFORM_NAME+x} && "$EFFECTIVE_PLATFORM_NAME" == *"maccatalyst" ]]; then
443
+ target_variant="maccatalyst"
444
+ fi
445
+ for i in ${!paths[@]}; do
446
+ local matched_all_archs="1"
447
+ for target_arch in $target_archs
448
+ do
449
+ if ! [[ "${paths[$i]}" == *"$target_variant"* ]]; then
450
+ matched_all_archs="0"
451
+ break
452
+ fi
453
+
454
+ # Verifies that the path contains the variant string (simulator or maccatalyst) if the variant is set.
455
+ if [[ -z "$target_variant" && ("${paths[$i]}" == *"simulator"* || "${paths[$i]}" == *"maccatalyst"*) ]]; then
456
+ matched_all_archs="0"
457
+ break
458
+ fi
459
+
460
+ # This regex matches all possible variants of the arch in the folder name:
461
+ # Let's say the folder name is: ios-armv7_armv7s_arm64_arm64e/CoconutLib.framework
462
+ # We match the following: -armv7_, _armv7s_, _arm64_ and _arm64e/.
463
+ # If we have a specific variant: ios-i386_x86_64-simulator/CoconutLib.framework
464
+ # We match the following: -i386_ and _x86_64-
465
+ # When the .xcframework wraps a static library, the folder name does not include
466
+ # any .framework. In that case, the folder name can be: ios-arm64_armv7
467
+ # We also match _armv7$ to handle that case.
468
+ local target_arch_regex="[_\\-]${target_arch}([\\/_\\-]|$)"
469
+ if ! [[ "${paths[$i]}" =~ $target_arch_regex ]]; then
470
+ matched_all_archs="0"
471
+ break
472
+ fi
473
+ done
474
+
475
+ if [[ "$matched_all_archs" == "1" ]]; then
476
+ # Found a matching slice
477
+ echo "Selected xcframework slice ${paths[$i]}"
478
+ SELECT_SLICE_RETVAL=${paths[$i]}
479
+ break
480
+ fi
481
+ done
482
+ }
483
+
484
+ install_library() {
485
+ local source="$1"
486
+ local name="$2"
487
+ local destination="${PODS_XCFRAMEWORKS_BUILD_DIR}/${name}"
488
+
489
+ # Libraries can contain headers, module maps, and a binary, so we'll copy everything in the folder over
490
+
491
+ local source="$binary"
492
+ echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \\"- CVS/\\" --filter \\"- .svn/\\" --filter \\"- .git/\\" --filter \\"- .hg/\\" \\"${source}/*\\" \\"${destination}\\""
493
+ rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" "${source}/*" "${destination}"
494
+ }
495
+
496
+ # Copies a framework to derived data for use in later build phases
497
+ install_framework()
498
+ {
499
+ local source="$1"
500
+ local name="$2"
501
+ local destination="${PODS_XCFRAMEWORKS_BUILD_DIR}/${name}"
502
+
503
+ if [ ! -d "$destination" ]; then
504
+ mkdir -p "$destination"
505
+ fi
506
+
507
+ copy_dir "$source" "$destination"
508
+ echo "Copied $source to $destination"
509
+ }
510
+
511
+ install_xcframework_library() {
512
+ local basepath="$1"
513
+ local name="$2"
514
+ local paths=("$@")
515
+
516
+ # Locate the correct slice of the .xcframework for the current architectures
517
+ select_slice "${paths[@]}"
518
+ local target_path="$SELECT_SLICE_RETVAL"
519
+ if [[ -z "$target_path" ]]; then
520
+ echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
521
+ return
522
+ fi
523
+
524
+ install_framework "$basepath/$target_path" "$name"
525
+ }
526
+
527
+ install_xcframework() {
528
+ local basepath="$1"
529
+ local name="$2"
530
+ local package_type="$3"
531
+ local paths=("$@")
532
+
533
+ # Locate the correct slice of the .xcframework for the current architectures
534
+ select_slice "${paths[@]}"
535
+ local target_path="$SELECT_SLICE_RETVAL"
536
+ if [[ -z "$target_path" ]]; then
537
+ echo "warning: [CP] Unable to find matching .xcframework slice in '${paths[@]}' for the current build architectures ($ARCHS)."
538
+ return
539
+ fi
540
+ local source="$basepath/$target_path"
541
+
542
+ local destination="${PODS_XCFRAMEWORKS_BUILD_DIR}/${name}"
543
+
544
+ if [ ! -d "$destination" ]; then
545
+ mkdir -p "$destination"
546
+ fi
547
+
548
+ copy_dir "$source/" "$destination"
549
+
550
+ echo "Copied $source to $destination"
551
+ }
552
+
553
+ install_xcframework "${PODS_ROOT}/_Frameworks/#{pod_name}.xcframework" "#{pod_name}" "framework" "ios-arm64_armv7" "ios-x86_64-simulator"
554
+ DESC
555
+ end
556
+ end
557
+ end
558
+
559
+ module Xcodeproj
560
+ class Project
561
+ def target_by_name(name)
562
+ targets.find { |t| t.name == name }
563
+ end
564
+
565
+ def group_by_name(name)
566
+ groups.find { |g| g.name == name }
567
+ end
568
+
569
+ module Object
570
+ class PBXGroup
571
+ def group_by_name(name)
572
+ groups.find { |g| g.name == name }
573
+ end
574
+ end
575
+ end
576
+ end
577
+ end
@@ -1,11 +1,11 @@
1
1
  require_relative 'dongjia_version_checker'
2
+ require_relative '../dongjia_binarization'
2
3
 
3
4
  module Pod
4
5
 
5
6
  class Installer
6
7
 
7
8
  class PodSourceInstaller
8
-
9
9
  # 关闭自己仓库中 pod 的安全警告
10
10
  old_method = instance_method(:verify_source_is_secure)
11
11
  define_method(:verify_source_is_secure) do |root_spec|
@@ -14,15 +14,29 @@ module Pod
14
14
  old_method.bind(self).(root_spec)
15
15
  end
16
16
  end
17
-
18
17
  end
19
18
 
19
+ # Hook post_installer
20
20
  origin_perform_post_install_actions = instance_method(:perform_post_install_actions)
21
21
  define_method :perform_post_install_actions do
22
22
  origin_perform_post_install_actions.bind(self).()
23
23
  Dongjia::DongjiaVersionChecker.check_version
24
24
  end
25
25
 
26
- end
26
+ # Hook Pods.xcodeproj 尚未写入
27
+ origin_run_podfile_post_install_hooks = instance_method(:run_podfile_post_install_hooks)
28
+ define_method :run_podfile_post_install_hooks do
29
+ origin_run_podfile_post_install_hooks.bind(self).()
30
+ # 处理二进制化
31
+ # Dongjia::Binarization.process(self)
32
+ end
27
33
 
34
+ # Hook Pods.xcodeproj 已生成完毕
35
+ origin_generate_pods_project = instance_method(:generate_pods_project)
36
+ define_method :generate_pods_project do
37
+ origin_generate_pods_project.bind(self).()
38
+ # 处理二进制化
39
+ Dongjia::Binarization.process(self)
40
+ end
41
+ end
28
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-dongjia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiangzhuoyi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.13.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: down
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 5.2.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 5.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: archive-zip
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.12.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.12.0
69
97
  description: A short description of cocoapods-dongjia.
70
98
  email:
71
99
  - jiangzhuoyi@idongjia.cn
@@ -83,26 +111,28 @@ files:
83
111
  - lib/cocoapods-dongjia/command/strip.rb
84
112
  - lib/cocoapods-dongjia/gem_version.rb
85
113
  - lib/cocoapods_plugin.rb
114
+ - lib/dongjia_binarization.rb
86
115
  - lib/dongjia_branch_inspector.rb
87
116
  - lib/dongjia_config.rb
88
117
  - lib/dongjia_enterprise_inspector.rb
89
118
  - lib/dongjia_pods_iterator.rb
90
119
  - lib/dongjia_router.rb
91
- - lib/dongjia_scheme_manager.rb
92
120
  - lib/dongjia_source.rb
93
121
  - lib/helper/Core/podfile/dsl.rb
94
122
  - lib/helper/dongjia_version_checker.rb
123
+ - lib/helper/installer.rb
95
124
  - lib/helper/pod.rb
96
125
  - lib/helper/podfile.rb
97
126
  - lib/helper/podfile_options.rb
98
- - lib/helper/podfile_warnings.rb
99
127
  - lib/helper/project.rb
100
128
  homepage: https://github.com/EXAMPLE/cocoapods-dongjia
101
129
  licenses:
102
130
  - MIT
103
131
  metadata:
104
- update_desc: " - 优化 post_install 行为,避免 install 后导致全量编译\n"
105
- post_install_message:
132
+ update_desc: |2
133
+ - 支持集成二进制版本的 Pod
134
+ - 优化 reinstall 命令
135
+ post_install_message:
106
136
  rdoc_options: []
107
137
  require_paths:
108
138
  - lib
@@ -117,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
147
  - !ruby/object:Gem::Version
118
148
  version: '0'
119
149
  requirements: []
120
- rubygems_version: 3.0.3
121
- signing_key:
150
+ rubygems_version: 3.2.19
151
+ signing_key:
122
152
  specification_version: 4
123
153
  summary: A longer description of cocoapods-dongjia.
124
154
  test_files: []
@@ -1,58 +0,0 @@
1
- require 'helper/project'
2
-
3
- module Dongjia
4
-
5
- class SchemeManager
6
-
7
- # 获取主工程的 development team
8
- def self.development_team(ctx)
9
- team = nil
10
- project = ctx.umbrella_targets.first.user_project
11
- return team unless project.is_a?(Xcodeproj::Project)
12
-
13
- target = project.targets.find { |t|
14
- !t.name.include?('企业版') && !t.name.end_with?('Extension')
15
- }
16
- return team unless target.is_a?(Xcodeproj::Project::PBXNativeTarget)
17
-
18
- build_cfg = target.build_configurations.find { |c| c.name == 'Debug' }
19
- return team unless build_cfg.is_a?(Xcodeproj::Project::XCBuildConfiguration)
20
-
21
- team = build_cfg.build_settings['DEVELOPMENT_TEAM']
22
- end
23
-
24
- def self.setup(ctx, params)
25
- visibled_appspecs = params[:visibled_appspecs]
26
- # return if !visibled_appspecs || visibled_appspecs.empty?
27
- sandbox_root = ctx.sandbox_root
28
-
29
- team = development_team(ctx)
30
-
31
- Dir.foreach(sandbox_root).select{|f| f.end_with?('xcodeproj')}.each do |name|
32
- proj = Xcodeproj::Project.open(File.join(sandbox_root, name))
33
- proj.targets.each do | target |
34
- # 确保是 appspec
35
- next unless target.name.include?('-')
36
- # 确保是可执行程序
37
- next unless target.product_type == 'com.apple.product-type.application'
38
-
39
- # 设置签名信息
40
- if team.is_a?(String)
41
- target.build_configurations.first.build_settings['DEVELOPMENT_TEAM'] = team
42
- target.build_configurations.each { |cfg|
43
- cfg.build_settings['DEVELOPMENT_TEAM'] = team
44
- }
45
- end
46
-
47
- if visibled_appspecs.include?(target.name.split('-').first)
48
- # 将 visibled_appspecs 中指定的 target 设为可见状态
49
- proj.set_target_scheme_visible(target, true)
50
- end
51
- end
52
- proj.save if team.is_a?(String)
53
- end
54
- end
55
-
56
- end
57
-
58
- end