cocoapods-dongjia 1.1.1 → 1.1.6

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: 126bfc1cf1fdf266d9b8d0801f531d8dab5b5656ed3f6f7392144c1b0782a564
4
- data.tar.gz: 27bf7cf27a82203f6bce0b6a4c289830b18f50cd909896a23595af038663d635
3
+ metadata.gz: dca107525ae9be1b7ed4f8bd40b5247cbcc5258035b9a0cc33ad4e4a96def6f3
4
+ data.tar.gz: c0d15ab36c6ad63daf5c82cffd1cbd8d41fc30d3a5ba1c1ddab2e3a468d2a36d
5
5
  SHA512:
6
- metadata.gz: f5e54d1dca186cdf7c45aed044ccdbd41df1125925fb40e11bb49ef981fe3994ec48625e1c9a7cd3a6d3fb3a193672bba541dd9255da0d754e9da469ed3e0c32
7
- data.tar.gz: 78a68150bdf76f6a27f358a7bda31f1f81542e30cfde5b58ef39c8487fe5eb645d00229e4f3516ab6a734f65525b3bb9612701c6e5b3d3a511640a5e9be0beef
6
+ metadata.gz: 43b4aa9ab668b94cfca481ab715c5de4f338f4ba22bfdc13c2c0cdbd673ed69aac48668fbe794f56c4a2babed20e527fc5e3c246ec485436b070b3dce02290f2
7
+ data.tar.gz: 364c8b20c8dd4c8c1e1255abeaf69049f57c656bb6690cbaea4153278a108d8f84d892505d63c21048cfedac2f55fae29c8fcc775f50c1d32829d67165ea1d55
@@ -1,5 +1,6 @@
1
1
  require 'cocoapods-dongjia/command/reinstall'
2
2
  require 'cocoapods-dongjia/command/install'
3
+ require 'cocoapods-dongjia/command/release'
3
4
  require 'cocoapods-dongjia/command/demo'
4
5
  require 'cocoapods-dongjia/command/strip'
5
6
  require 'cocoapods-dongjia/command/open'
@@ -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
@@ -0,0 +1,40 @@
1
+ require 'cocoapods'
2
+
3
+ module Pod
4
+
5
+ class Podfile
6
+ @@is_release_mode = false
7
+ def self.set_is_release_mode(mode)
8
+ @@is_release_mode = mode
9
+ end
10
+ def self.is_release_mode?
11
+ @@is_release_mode
12
+ end
13
+ end
14
+
15
+ class Command
16
+
17
+ class Release < Command
18
+
19
+ self.summary = '以 release 模式集成 pods'
20
+
21
+ self.description = <<-DESC
22
+
23
+ 以 release 模式集成 Pods
24
+
25
+ 可以在 Podfile 中通过 @@debug_only_pods = [pod_name] 的方式指定 debug 模式下的 Pod
26
+
27
+ 当执行 pod release 时,会自动剔除 @@debug_only_pods 内所定义的 Pod
28
+
29
+ DESC
30
+
31
+ def run
32
+ Pod::Podfile::set_is_release_mode(true)
33
+ installer_for_config.install!
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -104,17 +104,18 @@ module Pod
104
104
  def get_images
105
105
  images = Set[]
106
106
  except_dirs = [
107
- 'QYResource.bundle',
108
- 'DJMate',
109
- 'IQKeyboardManager',
110
- 'EnterpriseEditionImages.xcassets',
107
+ 'QYResource.bundle',
108
+ 'DJMate',
109
+ 'IQKeyboardManager',
111
110
  'MJRefresh.bundle',
112
111
  'AlipaySDK.bundle',
113
112
  'AppIcon.appiconset',
114
- 'KPCameraImages.xcassets'
113
+ 'KPCameraImages.xcassets',
114
+ 'UMSocialSDKResources.bundle',
115
+ 'LaunchResource'
115
116
  ]
116
117
  except_files = [
117
- 'image_placeholder',
118
+ 'image_placeholder',
118
119
  'register_add_avatar'
119
120
  ]
120
121
  bk = Proc.new do |dir, name, ext|
@@ -127,20 +128,32 @@ module Pod
127
128
 
128
129
  # 分析
129
130
  def analyze(source_files, images)
130
- source_files.map { |x| x.file_ref.real_path }.each do | path |
131
+ source_file_paths = source_files.map { |x|
132
+ x.file_ref.real_path
133
+ }
134
+ .select { |x|
135
+ File.exist?(x)
136
+ }
137
+ count = source_file_paths.count
138
+ source_file_paths.each_index do | index |
139
+ percent = index.to_f / count.to_f * 100
140
+ print "\r" if index != 0
141
+ print "#{format("%.2f", percent)}%"
142
+ path = source_file_paths[index]
131
143
  File.open(path, 'r') do |f|
132
144
  image_using = []
133
145
  f.each_line do |line|
134
146
  next unless line.include?('"')
135
- images.each do |img|
136
- if line.include?('"' + img.name)
137
- image_using << img
138
- else
139
- # 根据下划线分割剔除最后一项,再尝试匹配
140
- if !img.fuzzy_name.empty?
141
- if line.include?('"' + img.fuzzy_name + '%') ||
142
- line.include?('"' + img.fuzzy_name + '"')
143
- image_using << img
147
+ ['"', '/'].each do |prefix|
148
+ images.each do |img|
149
+ if line.include?(prefix + img.name)
150
+ image_using << img
151
+ else
152
+ # 根据下划线分割剔除最后一项,再尝试匹配
153
+ if !img.fuzzy_name.empty?
154
+ ['%', '"'].each do |suffix|
155
+ image_using << img if line.include?(prefix + img.fuzzy_name + suffix)
156
+ end
144
157
  end
145
158
  end
146
159
  end
@@ -149,15 +162,20 @@ module Pod
149
162
  images = images - image_using
150
163
  end
151
164
  end
165
+ print "\r"
152
166
  images
153
167
  end
154
168
 
155
169
  def run
156
170
  images = analyze(get_source_files, get_images)
157
- puts "无效资源文件:"
158
- images.each do |img|
159
- path = Pathname.new(img.fullpath).relative_path_from(Dir.pwd).to_s
160
- puts " #{path}"
171
+ if images.empty?
172
+ puts "未找到无效资源"
173
+ else
174
+ puts "无效资源文件:"
175
+ images.each do |img|
176
+ path = Pathname.new(img.fullpath).relative_path_from(Dir.pwd).to_s
177
+ puts " #{path}"
178
+ end
161
179
  end
162
180
  end
163
181
 
@@ -1,6 +1,7 @@
1
1
  module CocoapodsDongjia
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.6"
3
3
  UPDATE_DESC = <<-EOS
4
- - 修复依赖
4
+ - 支持集成二进制版本的 Pod
5
+ - 优化 reinstall 命令
5
6
  EOS
6
7
  end
@@ -4,16 +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
- require_relative 'helper/podfile_local_importer'
9
+ require_relative 'helper/podfile'
10
10
  require_relative 'helper/podfile_options'
11
- require_relative 'helper/podfile_warnings'
11
+ require_relative 'helper/installer'
12
+ require_relative 'helper/Core/podfile/dsl'
12
13
 
13
14
  module Dongjia
14
15
 
15
16
  Pod::HooksManager.register('cocoapods-dongjia', :pre_install) do |ctx, params|
16
17
 
18
+ Binarization.load_private_config(ctx)
19
+
20
+ Binarization.remove_dirty_pod_projects()
21
+
17
22
  podfile = ctx.podfile
18
23
 
19
24
  # 禁用集成完后的反馈
@@ -24,7 +29,6 @@ module Dongjia
24
29
 
25
30
  # 关闭静态框架依赖传递的校验
26
31
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
27
-
28
32
  end
29
33
 
30
34
  Pod::HooksManager.register('cocoapods-dongjia', :post_install) do |ctx, params|
@@ -32,17 +36,8 @@ module Dongjia
32
36
  # 关闭警告 / 检查 LTO
33
37
  PodsIterator.iterate(params, ctx.sandbox_root)
34
38
 
35
- # 处理 appspec 配置
36
- SchemeManager.setup(ctx, params)
37
-
38
- # 企业版文件引用校验
39
- files = EnterpriseInspector.inspect()
40
- Pod::UI.warn "文件未加入企业版:#{files}" if files.count > 0
41
-
42
39
  # 抓取所有路由汇总至
43
- router = Router.new
44
- router.scrape_routers(ctx.sandbox_root, params[:scrap_routers])
45
-
40
+ # router = Router.new
41
+ # router.scrape_routers(ctx.sandbox_root, params[:scrap_routers])
46
42
  end
47
-
48
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
@@ -4,38 +4,62 @@ module Dongjia
4
4
 
5
5
  class PodsIterator
6
6
 
7
+ def self.update_build_setting(config, key, value)
8
+ if config.build_settings[key] != value
9
+ config.build_settings[key] = value
10
+ return true
11
+ else
12
+ return false
13
+ end
14
+ end
15
+
7
16
  # 关闭警告
8
17
  def self.disable_warnings(config, target_name)
18
+ changed = false
19
+
9
20
  # 禁用非 DJ 开头 Pod 的警告
10
- config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES" unless target_name.start_with?('DJ')
11
-
21
+ changed ||= update_build_setting(config, 'GCC_WARN_INHIBIT_ALL_WARNINGS', 'YES') unless target_name.start_with?('DJ')
22
+
12
23
  # 不检测 block 中的隐式 self 调用
13
- config.build_settings['CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF'] = "NO"
24
+ changed ||= update_build_setting(config, 'CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF', "NO")
14
25
 
15
26
  # 不检测已废弃的方法
16
- config.build_settings['GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS'] = "NO"
17
-
18
- # 允许 objc_msgSend
19
- config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
27
+ changed ||= update_build_setting(config, 'GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS', "NO")
20
28
 
21
29
  # 不检测注释
22
- config.build_settings['CLANG_WARN_DOCUMENTATION_COMMENTS'] = "NO"
30
+ changed ||= update_build_setting(config, 'CLANG_WARN_DOCUMENTATION_COMMENTS', "NO")
23
31
 
24
- # 不严格的原型校验
25
- config.build_settings['CLANG_WARN_STRICT_PROTOTYPES'] = "NO"
26
-
27
- # 强制设置 deployment 版本为 8.0
28
- if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
29
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
32
+ # 强制设置 deployment 版本为 9.0
33
+ if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 9.0
34
+ changed ||= update_build_setting(config, 'IPHONEOS_DEPLOYMENT_TARGET', "9.0")
30
35
  end
31
36
 
32
37
  # 关闭 bitcode
33
- config.build_settings['ENABLE_BITCODE'] = "NO"
38
+ changed ||= update_build_setting(config, 'ENABLE_BITCODE', "NO")
39
+
40
+ changed
34
41
  end
35
42
 
36
43
  # 打开 LTO
37
44
  def self.enable_lto(config)
38
- config.build_settings['LLVM_LTO'] = 'YES_THIN' if config.name == 'Release'
45
+ changed = false
46
+ # changed ||= update_build_setting(config, 'LLVM_LTO', 'YES_THIN') if config.name == 'Release'
47
+ changed
48
+ end
49
+
50
+ # 将 umbrella 导出的头文件改为尖括号形式
51
+ def self.convert_umbrella_header_import(pod_name)
52
+ umbrella_path = "./Pods/Target Support Files/#{pod_name}/#{pod_name}-umbrella.h"
53
+ return unless File.exist?(umbrella_path)
54
+ contents = File.read(umbrella_path)
55
+ return unless contents.include?("#import \"")
56
+ File.open(umbrella_path, 'r+') do |f|
57
+ x = f.read
58
+ begin x.gsub!("#import \"#{pod_name}/", "#import <#{pod_name}/").gsub!('.h"', '.h>') rescue nil end
59
+ begin x.gsub!('#import "', "#import <#{pod_name}/").gsub!('.h"', '.h>') rescue nil end
60
+ f.rewind
61
+ f.write(x)
62
+ end
39
63
  end
40
64
 
41
65
  # 遍历所有 Pod 工程配置
@@ -50,23 +74,27 @@ module Dongjia
50
74
 
51
75
  if name != 'Pods.xcodeproj'
52
76
  proj.build_configurations.each do | config |
53
- # 强制设置 deployment 版本为 8.0
54
- if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 8.0
55
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "8.0"
77
+ # 强制设置 deployment 版本为 9.0
78
+ if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 9.0
79
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "9.0"
56
80
  end
57
81
  end
58
82
  end
59
83
 
60
84
  # project 的每个 target 配置
85
+ changed = false
61
86
  proj.targets.select {|t| !t.name.start_with?('Pods')}.each do | target |
62
87
  next if target.name.start_with?('Pods')
63
88
  target.build_configurations.each do | config |
64
- disable_warnings(config, target.name) if turn_off_warnings
65
- enable_lto(config) if lto_enabled
89
+ changed ||= disable_warnings(config, target.name) if turn_off_warnings
90
+ changed ||= enable_lto(config) if lto_enabled
91
+ convert_umbrella_header_import(target.name)
66
92
  end
67
93
  end
68
94
 
69
- proj.save
95
+ if changed
96
+ proj.save
97
+ end
70
98
 
71
99
  end
72
100
 
@@ -14,6 +14,8 @@ module Dongjia
14
14
 
15
15
  注意:此处的实现仅供查看,如需修改,请点击对应的 _redirect{type} 方法跳转至对应的实现
16
16
 
17
+ 跳转定义文档:https://cf.idongjia.cn/pages/viewpage.action?pageId=57351032
18
+
17
19
  */
18
20
 
19
21
 
@@ -39,7 +41,10 @@ EOS
39
41
  end
40
42
 
41
43
  if @prefix != nil
42
- @redirect_type = @defining_line[prefix_len, @defining_line.index(',') - prefix_len]
44
+ end_index = @defining_line.index(',') || @defining_line.index(')')
45
+ if !end_index.nil?
46
+ @redirect_type = @defining_line[prefix_len, end_index - prefix_len]
47
+ end
43
48
  end
44
49
  end
45
50
 
@@ -0,0 +1,16 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+ # Hook Podfile 中的 install: 方法,将当前版本 Cocoapods 不支持的 option 剔除
5
+ original_install = instance_method(:install!)
6
+ define_method(:install!) do |installation_method, options = {}|
7
+ all_options = Installer::InstallationOptions::all_options
8
+ valid_options = {}
9
+ options.each do |k, v|
10
+ valid_options.merge!({k => v}) if all_options.include?(k.to_s)
11
+ end
12
+ original_install.bind(self).(installation_method, valid_options)
13
+ end
14
+ end
15
+ end
16
+ 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
@@ -0,0 +1,60 @@
1
+ require_relative 'pod'
2
+
3
+ module Pod
4
+
5
+ class LocalSpec
6
+ @@local_spec_importing = false
7
+ @@local_spec_path = nil
8
+ def self.import_local_pod(path)
9
+ @@local_spec_importing = true
10
+ @@local_spec_path = path
11
+ yield if block_given?
12
+ @@local_spec_path = nil
13
+ @@local_spec_importing = false
14
+ end
15
+ def self.local_spec_importing?
16
+ @@local_spec_importing
17
+ end
18
+ def self.local_spec_path
19
+ @@local_spec_path
20
+ end
21
+ end
22
+
23
+ class Podfile
24
+
25
+ # 只在 debug 模式下集成的组件,默认为空
26
+ @@debug_only_pods = []
27
+
28
+ # 导入工程目录下相对位置的 pod
29
+ def import_relative_in(path = './')
30
+ LocalSpec.import_local_pod(path) do
31
+ yield if block_given?
32
+ end
33
+ end
34
+
35
+ original_pod = instance_method(:pod)
36
+ define_method(:pod) do |name = nil, *requirements|
37
+
38
+ if Pod::Podfile::is_release_mode?
39
+ realname = name.split('/').first
40
+ if @@debug_only_pods.include?(realname)
41
+ puts "#{realname} is only for debug, it will be removed."
42
+ next
43
+ end
44
+ end
45
+
46
+ if LocalSpec.local_spec_importing?
47
+ path_cfg = { :path => "#{LocalSpec.local_spec_path}/#{Pod::repo_name(name)}" }
48
+ if requirements.length == 0
49
+ requirements = [path_cfg]
50
+ else
51
+ cfg = requirements.first
52
+ cfg.merge!(path_cfg) unless cfg.has_key?(:path)
53
+ end
54
+ end
55
+ original_pod.bind(self).(name, *requirements)
56
+ end
57
+
58
+ end
59
+
60
+ 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.1
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-03-23 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
@@ -79,28 +107,32 @@ files:
79
107
  - lib/cocoapods-dongjia/command/install.rb
80
108
  - lib/cocoapods-dongjia/command/open.rb
81
109
  - lib/cocoapods-dongjia/command/reinstall.rb
110
+ - lib/cocoapods-dongjia/command/release.rb
82
111
  - lib/cocoapods-dongjia/command/strip.rb
83
112
  - lib/cocoapods-dongjia/gem_version.rb
84
113
  - lib/cocoapods_plugin.rb
114
+ - lib/dongjia_binarization.rb
85
115
  - lib/dongjia_branch_inspector.rb
86
116
  - lib/dongjia_config.rb
87
117
  - lib/dongjia_enterprise_inspector.rb
88
118
  - lib/dongjia_pods_iterator.rb
89
119
  - lib/dongjia_router.rb
90
- - lib/dongjia_scheme_manager.rb
91
120
  - lib/dongjia_source.rb
121
+ - lib/helper/Core/podfile/dsl.rb
92
122
  - lib/helper/dongjia_version_checker.rb
123
+ - lib/helper/installer.rb
93
124
  - lib/helper/pod.rb
94
- - lib/helper/podfile_local_importer.rb
125
+ - lib/helper/podfile.rb
95
126
  - lib/helper/podfile_options.rb
96
- - lib/helper/podfile_warnings.rb
97
127
  - lib/helper/project.rb
98
128
  homepage: https://github.com/EXAMPLE/cocoapods-dongjia
99
129
  licenses:
100
130
  - MIT
101
131
  metadata:
102
- update_desc: " - 修复依赖\n"
103
- post_install_message:
132
+ update_desc: |2
133
+ - 支持集成二进制版本的 Pod
134
+ - 优化 reinstall 命令
135
+ post_install_message:
104
136
  rdoc_options: []
105
137
  require_paths:
106
138
  - lib
@@ -115,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
147
  - !ruby/object:Gem::Version
116
148
  version: '0'
117
149
  requirements: []
118
- rubygems_version: 3.0.3
119
- signing_key:
150
+ rubygems_version: 3.2.19
151
+ signing_key:
120
152
  specification_version: 4
121
153
  summary: A longer description of cocoapods-dongjia.
122
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
@@ -1,34 +0,0 @@
1
- require_relative 'pod'
2
-
3
- module Pod
4
-
5
- class Podfile
6
-
7
- # 导入工程目录下相对位置的 pod
8
- @local_spec_importing = false
9
- @local_spec_path = nil
10
- def import_relative_in(path = './')
11
- @local_spec_importing = true
12
- @local_spec_path = path
13
- yield if block_given?
14
- @local_spec_path = nil
15
- @local_spec_importing = false
16
- end
17
-
18
- original_pod = instance_method(:pod)
19
- define_method(:pod) do |name = nil, *requirements|
20
- if @local_spec_importing
21
- path_cfg = { :path => "#{@local_spec_path}/#{Pod::repo_name(name)}" }
22
- if requirements.length == 0
23
- requirements = [path_cfg]
24
- else
25
- cfg = requirements.first
26
- cfg.merge!(path_cfg) unless cfg.has_key?(:path)
27
- end
28
- end
29
- original_pod.bind(self).(name, *requirements)
30
- end
31
-
32
- end
33
-
34
- end