cocoapods-mtxx-bin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +22 -0
  3. data/README.md +11 -0
  4. data/lib/cocoapods-mtxx-bin/command/bin/archive.rb +206 -0
  5. data/lib/cocoapods-mtxx-bin/command/bin/auto.rb +212 -0
  6. data/lib/cocoapods-mtxx-bin/command/bin/code.rb +232 -0
  7. data/lib/cocoapods-mtxx-bin/command/bin/imy.rb +45 -0
  8. data/lib/cocoapods-mtxx-bin/command/bin/init.rb +94 -0
  9. data/lib/cocoapods-mtxx-bin/command/bin/initHotKey.rb +70 -0
  10. data/lib/cocoapods-mtxx-bin/command/bin/install.rb +44 -0
  11. data/lib/cocoapods-mtxx-bin/command/bin/lib/lint.rb +67 -0
  12. data/lib/cocoapods-mtxx-bin/command/bin/repo/push.rb +115 -0
  13. data/lib/cocoapods-mtxx-bin/command/bin/repo/update.rb +42 -0
  14. data/lib/cocoapods-mtxx-bin/command/bin/repo.rb +14 -0
  15. data/lib/cocoapods-mtxx-bin/command/bin/spec/create.rb +73 -0
  16. data/lib/cocoapods-mtxx-bin/command/bin/spec/lint.rb +109 -0
  17. data/lib/cocoapods-mtxx-bin/command/bin/spec.rb +13 -0
  18. data/lib/cocoapods-mtxx-bin/command/bin/update.rb +154 -0
  19. data/lib/cocoapods-mtxx-bin/command/bin.rb +65 -0
  20. data/lib/cocoapods-mtxx-bin/command.rb +1 -0
  21. data/lib/cocoapods-mtxx-bin/config/config.rb +166 -0
  22. data/lib/cocoapods-mtxx-bin/config/config_asker.rb +60 -0
  23. data/lib/cocoapods-mtxx-bin/config/config_builder.rb +216 -0
  24. data/lib/cocoapods-mtxx-bin/config/config_hot_key.rb +103 -0
  25. data/lib/cocoapods-mtxx-bin/config/config_hot_key_asker.rb +57 -0
  26. data/lib/cocoapods-mtxx-bin/gem_version.rb +9 -0
  27. data/lib/cocoapods-mtxx-bin/helpers/Info.plist +0 -0
  28. data/lib/cocoapods-mtxx-bin/helpers/build_helper.rb +167 -0
  29. data/lib/cocoapods-mtxx-bin/helpers/build_utils.rb +64 -0
  30. data/lib/cocoapods-mtxx-bin/helpers/framework.rb +86 -0
  31. data/lib/cocoapods-mtxx-bin/helpers/framework_builder.rb +551 -0
  32. data/lib/cocoapods-mtxx-bin/helpers/library.rb +54 -0
  33. data/lib/cocoapods-mtxx-bin/helpers/library_builder.rb +90 -0
  34. data/lib/cocoapods-mtxx-bin/helpers/sources_helper.rb +35 -0
  35. data/lib/cocoapods-mtxx-bin/helpers/spec_creator.rb +170 -0
  36. data/lib/cocoapods-mtxx-bin/helpers/spec_files_helper.rb +80 -0
  37. data/lib/cocoapods-mtxx-bin/helpers/spec_source_creator.rb +304 -0
  38. data/lib/cocoapods-mtxx-bin/helpers/upload_helper.rb +104 -0
  39. data/lib/cocoapods-mtxx-bin/helpers.rb +5 -0
  40. data/lib/cocoapods-mtxx-bin/native/acknowledgements.rb +27 -0
  41. data/lib/cocoapods-mtxx-bin/native/analyzer.rb +85 -0
  42. data/lib/cocoapods-mtxx-bin/native/file_accessor.rb +28 -0
  43. data/lib/cocoapods-mtxx-bin/native/gen.rb +79 -0
  44. data/lib/cocoapods-mtxx-bin/native/installation_options.rb +25 -0
  45. data/lib/cocoapods-mtxx-bin/native/installer.rb +135 -0
  46. data/lib/cocoapods-mtxx-bin/native/linter.rb +26 -0
  47. data/lib/cocoapods-mtxx-bin/native/path_source.rb +33 -0
  48. data/lib/cocoapods-mtxx-bin/native/pod_source_installer.rb +19 -0
  49. data/lib/cocoapods-mtxx-bin/native/pod_target_installer.rb +94 -0
  50. data/lib/cocoapods-mtxx-bin/native/podfile.rb +91 -0
  51. data/lib/cocoapods-mtxx-bin/native/podfile_env.rb +37 -0
  52. data/lib/cocoapods-mtxx-bin/native/podfile_generator.rb +201 -0
  53. data/lib/cocoapods-mtxx-bin/native/podspec_finder.rb +25 -0
  54. data/lib/cocoapods-mtxx-bin/native/resolver.rb +238 -0
  55. data/lib/cocoapods-mtxx-bin/native/sandbox_analyzer.rb +34 -0
  56. data/lib/cocoapods-mtxx-bin/native/source.rb +35 -0
  57. data/lib/cocoapods-mtxx-bin/native/sources_manager.rb +19 -0
  58. data/lib/cocoapods-mtxx-bin/native/specification.rb +31 -0
  59. data/lib/cocoapods-mtxx-bin/native/target_validator.rb +41 -0
  60. data/lib/cocoapods-mtxx-bin/native/validator.rb +40 -0
  61. data/lib/cocoapods-mtxx-bin/native.rb +25 -0
  62. data/lib/cocoapods-mtxx-bin/source_provider_hook.rb +53 -0
  63. data/lib/cocoapods-mtxx-bin.rb +2 -0
  64. data/lib/cocoapods_plugin.rb +2 -0
  65. data/spec/command/bin_spec.rb +12 -0
  66. data/spec/spec_helper.rb +50 -0
  67. metadata +182 -0
@@ -0,0 +1,201 @@
1
+
2
+
3
+ require 'parallel'
4
+ require 'cocoapods'
5
+ require 'cocoapods-mtxx-bin/native/pod_source_installer'
6
+
7
+
8
+ require 'parallel'
9
+ require 'cocoapods'
10
+
11
+ module Pod
12
+ module Generate
13
+ # Generates podfiles for pod specifications given a configuration.
14
+ #
15
+ class PodfileGenerator
16
+ # @return [Podfile] a podfile suitable for installing the given spec
17
+ #
18
+ # @param [Specification] spec
19
+ #
20
+ alias old_podfile_for_spec podfile_for_spec
21
+
22
+ def podfile_for_spec(spec)
23
+ generator = self
24
+ dir = configuration.gen_dir_for_pod(spec.name)
25
+
26
+ Pod::Podfile.new do
27
+ project "#{spec.name}.xcodeproj"
28
+ workspace "#{spec.name}.xcworkspace"
29
+
30
+ plugin 'cocoapods-generate'
31
+
32
+ install! 'cocoapods', generator.installation_options
33
+
34
+ generator.podfile_plugins.each do |name, options|
35
+ plugin(*[name, options].compact)
36
+ end
37
+
38
+ # use_frameworks!(generator.use_frameworks_value)
39
+ # 强制生成 static framework
40
+ use_frameworks!({:linkage=>:static, :packaging=>:framework})
41
+
42
+ if (supported_swift_versions = generator.supported_swift_versions)
43
+ supports_swift_versions(supported_swift_versions)
44
+ end
45
+
46
+ # Explicitly set sources
47
+ generator.configuration.sources.each do |source_url|
48
+ source(source_url)
49
+ end
50
+
51
+ self.defined_in_file = dir.join('CocoaPods.podfile.yaml')
52
+
53
+ test_specs = spec.recursive_subspecs.select(&:test_specification?)
54
+ app_specs = if spec.respond_to?(:app_specification?)
55
+ spec.recursive_subspecs.select(&:app_specification?)
56
+ else
57
+ []
58
+ end
59
+
60
+ # Stick all of the transitive dependencies in an abstract target.
61
+ # This allows us to force CocoaPods to use the versions / sources / external sources
62
+ # that we want.
63
+ # By using an abstract target,
64
+
65
+ # 会导致多个dependencies出现, 注释by slj
66
+ # abstract_target 'Transitive Dependencies' do
67
+ # pods_for_transitive_dependencies = [spec.name]
68
+ # .concat(test_specs.map(&:name))
69
+ # .concat(test_specs.flat_map { |ts| ts.dependencies.flat_map(&:name) })
70
+ # .concat(app_specs.map(&:name))
71
+ # .concat(app_specs.flat_map { |as| as.dependencies.flat_map(&:name) })
72
+ #
73
+ # dependencies = generator
74
+ # .transitive_dependencies_by_pod
75
+ # .values_at(*pods_for_transitive_dependencies)
76
+ # .compact
77
+ # .flatten(1)
78
+ # .uniq
79
+ # .sort_by(&:name)
80
+ # .reject { |d| d.root_name == spec.root.name }
81
+ #
82
+ # dependencies.each do |dependency|
83
+ # pod_args = generator.pod_args_for_dependency(self, dependency)
84
+ # pod(*pod_args)
85
+ # end
86
+ # end
87
+
88
+ # Add platform-specific concrete targets that inherit the
89
+ # `pod` declaration for the local pod.
90
+ spec_platform_names = spec.available_platforms.map(&:string_name).flatten.each.reject do |platform_name|
91
+ !generator.configuration.platforms.nil? && !generator.configuration.platforms.include?(platform_name.downcase)
92
+ end
93
+
94
+ spec_platform_names.sort.each do |platform_name|
95
+ target "App-#{platform_name}" do
96
+ current_target_definition.swift_version = generator.swift_version if generator.swift_version
97
+ end
98
+ end
99
+
100
+ # this block has to come _before_ inhibit_all_warnings! / use_modular_headers!,
101
+ # and the local `pod` declaration
102
+ # 会导致多个dependencies出现, 注释by slj
103
+
104
+
105
+ inhibit_all_warnings! if generator.inhibit_all_warnings?
106
+ use_modular_headers! if generator.use_modular_headers?
107
+
108
+ # This is the pod declaration for the local pod,
109
+ # it will be inherited by the concrete target definitions below
110
+
111
+ pod_options = generator.dependency_compilation_kwargs(spec.name)
112
+ pod_options[:path] = spec.defined_in_file.relative_path_from(dir).to_s
113
+ # generator.configuration.podfile.dependencies[0].external_source
114
+
115
+
116
+ { testspecs: test_specs, appspecs: app_specs }.each do |key, specs|
117
+ pod_options[key] = specs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless specs.empty?
118
+ end
119
+
120
+ pod spec.name, **pod_options
121
+
122
+ if Pod::Config.instance.podfile
123
+ target_definitions['Pods'].instance_exec do
124
+ target_definition = nil
125
+ Pod::Config.instance.podfile.target_definition_list.each do |target|
126
+ if target.label == "Pods-#{spec.name}"
127
+ target_definition = target
128
+ break
129
+ end
130
+ end
131
+ # setting modular_headers_for
132
+ if(target_definition && target_definition.use_modular_headers_hash.values.any?)
133
+ target_definition.use_modular_headers_hash.values.each do |f|
134
+ f.each { | pod_name| self.set_use_modular_headers_for_pod(pod_name, true) }
135
+ end
136
+ end
137
+
138
+
139
+ if target_definition
140
+ value = target_definition.to_hash['dependencies']
141
+ next if value.blank?
142
+ #删除 本地库中的 spec.name,因为本地的./spec.name地址是错的
143
+ value.each do |f|
144
+ if f.is_a?(Hash) && f.keys.first == spec.name
145
+ value.delete f
146
+ break
147
+ end
148
+ end
149
+ old_value = self.to_hash['dependencies'].first
150
+ value << old_value unless (old_value == nil || value.include?(old_value))
151
+
152
+ set_hash_value(%w(dependencies).first, value)
153
+
154
+ value = target_definition.to_hash['configuration_pod_whitelist']
155
+ next if value.blank?
156
+ set_hash_value(%w(configuration_pod_whitelist).first, value)
157
+
158
+
159
+ end
160
+
161
+
162
+ end
163
+
164
+ end
165
+
166
+ # if generator.configuration && generator.configuration.podfile
167
+ # #变量本地podfile下的dependencies 写入新的验证文件中,指定依赖源
168
+ # generator.configuration.podfile.dependencies.each { |dependencies|
169
+ # #如果不存在dependencies.external_source,就不变量
170
+ # next unless dependencies.external_source
171
+ #
172
+ # dependencies.external_source.each { |key_d, value|
173
+ # pod_options = generator.dependency_compilation_kwargs(dependencies.name)
174
+ # pod_options[key_d] = value.to_s
175
+ # { testspecs: test_specs, appspecs: app_specs }.each do |key, specs|
176
+ # pod_options[key] = specs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless specs.empty?
177
+ # end
178
+ # # 过滤 dependencies.name == spec.name
179
+ # pod(dependencies.name, **pod_options) unless dependencies.name == spec.name
180
+ # }
181
+ # }
182
+ # end
183
+
184
+
185
+ # Implement local-sources option to set up dependencies to podspecs in the local filesystem.
186
+ next if generator.configuration.local_sources.empty?
187
+ generator.transitive_local_dependencies(spec, generator.configuration.local_sources).each do |dependency, podspec_file|
188
+ pod_options = generator.dependency_compilation_kwargs(dependency.name)
189
+ pod_options[:path] = if podspec_file[0] == '/' # absolute path
190
+ podspec_file
191
+ else
192
+ '../../' + podspec_file
193
+ end
194
+ pod dependency.name, **pod_options
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+ end
201
+
@@ -0,0 +1,25 @@
1
+
2
+
3
+ require 'cocoapods-mtxx-bin/native/specification'
4
+
5
+ module Pod
6
+ class Sandbox
7
+ class PodspecFinder
8
+ def podspecs
9
+ return @specs_by_name if @specs_by_name
10
+
11
+ @specs_by_name = {}
12
+ spec_files = Pathname.glob(root + '{,*}.podspec{,.json}')
13
+ # pod 指向分支时,如果目标组件有 subspec ,并且有 template spec ,request 之后使用的 spec 不应该为 template spec
14
+ # 这里做下过滤
15
+ spec_files = spec_files.reject { |p| Specification::DEFAULT_TEMPLATE_EXTNAME.find { |e| p.to_s.end_with?(e) } }
16
+ spec_files.sort_by { |p| -p.to_path.split(File::SEPARATOR).size }.each do |file|
17
+ spec = Specification.from_file(file)
18
+ spec.validate_cocoapods_version
19
+ @specs_by_name[spec.name] = spec
20
+ end
21
+ @specs_by_name
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,238 @@
1
+
2
+
3
+ require 'parallel'
4
+ require 'cocoapods'
5
+ require 'cocoapods-mtxx-bin/native/podfile'
6
+ require 'cocoapods-mtxx-bin/native/sources_manager'
7
+ require 'cocoapods-mtxx-bin/native/installation_options'
8
+ require 'cocoapods-mtxx-bin/gem_version'
9
+ require 'cocoapods-mtxx-bin/command/bin/archive'
10
+
11
+ module Pod
12
+ class Resolver
13
+ if Pod.match_version?('~> 1.6')
14
+ # 其实不用到 resolver_specs_by_target 再改 spec
15
+ # 在这个方法里面,通过修改 dependency 的 source 应该也可以
16
+ # 就是有一点,如果改了之后,对应的 source 没有符合 dependency 的版本
17
+ # 分析依赖阶段就会报错了,没法像 resolver_specs_by_target 一样
18
+ # 没有对应的二进制版本时还可以转到源码源码
19
+ #
20
+ def aggregate_for_dependency(dependency)
21
+ sources_manager = Config.instance.sources_manager
22
+ if dependency&.podspec_repo
23
+ sources_manager.aggregate_for_dependency(dependency)
24
+ # 采用 lock 中的 source ,会导致插件对 source 的先后调整失效
25
+ # elsif (locked_vertex = @locked_dependencies.vertex_named(dependency.name)) && (locked_dependency = locked_vertex.payload) && locked_dependency.podspec_repo
26
+ # sources_manager.aggregate_for_dependency(locked_dependency)
27
+ else
28
+ @aggregate ||= Source::Aggregate.new(sources)
29
+ end
30
+ end
31
+ end
32
+
33
+ if Pod.match_version?('~> 1.4')
34
+ def specifications_for_dependency(dependency, additional_requirements_frozen = [])
35
+ additional_requirements = additional_requirements_frozen.dup.compact
36
+ requirement = Requirement.new(dependency.requirement.as_list + additional_requirements.flat_map(&:as_list))
37
+ if podfile.allow_prerelease? && !requirement.prerelease?
38
+ requirement = Requirement.new(dependency.requirement.as_list.map { |r| r + '.a' } + additional_requirements.flat_map(&:as_list))
39
+ end
40
+
41
+ options = if Pod.match_version?('~> 1.7')
42
+ podfile.installation_options
43
+ else
44
+ installation_options
45
+ end
46
+
47
+ if Pod.match_version?('~> 1.8')
48
+ specifications = find_cached_set(dependency)
49
+ .all_specifications(options.warn_for_multiple_pod_sources, requirement)
50
+ else
51
+ specifications = find_cached_set(dependency)
52
+ .all_specifications(options.warn_for_multiple_pod_sources)
53
+ .select { |s| requirement.satisfied_by? s.version }
54
+ end
55
+
56
+ specifications
57
+ .map { |s| s.subspec_by_name(dependency.name, false, true) }
58
+ .compact
59
+ end
60
+ end
61
+
62
+ if Pod.match_version?('~> 1.6')
63
+ alias old_valid_possibility_version_for_root_name? valid_possibility_version_for_root_name?
64
+
65
+ def valid_possibility_version_for_root_name?(requirement, activated, spec)
66
+ return true if podfile.allow_prerelease?
67
+
68
+ old_valid_possibility_version_for_root_name?(requirement, activated, spec)
69
+ end
70
+ elsif Pod.match_version?('~> 1.4')
71
+ def requirement_satisfied_by?(requirement, activated, spec)
72
+ version = spec.version
73
+ return false unless requirement.requirement.satisfied_by?(version)
74
+
75
+ shared_possibility_versions, prerelease_requirement = possibility_versions_for_root_name(requirement, activated)
76
+ if !shared_possibility_versions.empty? && !shared_possibility_versions.include?(version)
77
+ return false
78
+ end
79
+ if !podfile.allow_prerelease? && version.prerelease? && !prerelease_requirement
80
+ return false
81
+ end
82
+ unless spec_is_platform_compatible?(activated, requirement, spec)
83
+ return false
84
+ end
85
+
86
+ true
87
+ end
88
+ end
89
+
90
+ # >= 1.4.0 才有 resolver_specs_by_target 以及 ResolverSpecification
91
+ # >= 1.5.0 ResolverSpecification 才有 source,供 install 或者其他操作时,输入 source 变更
92
+ #
93
+ if Pod.match_version?('~> 1.4')
94
+ old_resolver_specs_by_target = instance_method(:resolver_specs_by_target)
95
+ define_method(:resolver_specs_by_target) do
96
+ specs_by_target = old_resolver_specs_by_target.bind(self).call
97
+
98
+ sources_manager = Config.instance.sources_manager
99
+ use_source_pods = podfile.use_source_pods
100
+
101
+ missing_binary_specs = []
102
+ specs_by_target.each do |target, rspecs|
103
+ # use_binaries 并且 use_source_pods 不包含 本地可过滤
104
+ use_binary_rspecs = if podfile.use_binaries? || podfile.use_binaries_selector
105
+ rspecs.select do |rspec|
106
+ ([rspec.name, rspec.root.name] & use_source_pods).empty? &&
107
+ (podfile.use_binaries_selector.nil? || podfile.use_binaries_selector.call(rspec.spec))
108
+ end
109
+ else
110
+ []
111
+ end
112
+
113
+ # Parallel.map(rspecs, in_threads: 8) do |rspec|
114
+ specs_by_target[target] = rspecs.map do |rspec|
115
+ # 含有 subspecs 的组件暂不处理
116
+ # next rspec if rspec.spec.subspec? || rspec.spec.subspecs.any?
117
+
118
+ # developments 组件采用默认输入的 spec (development pods 的 source 为 nil)
119
+ # 可以使 :podspec => "htts://IMYFoundation.podspec"可以走下去,by slj
120
+ unless rspec.spec.respond_to?(:spec_source) && rspec.spec.spec_source
121
+ next rspec
122
+ end
123
+
124
+ # 采用二进制依赖并且不为开发组件
125
+ use_binary = use_binary_rspecs.include?(rspec)
126
+ if use_binary
127
+ source = sources_manager.binary_source
128
+ else
129
+ # 获取podfile中的source
130
+ podfile_sources = podfile.sources.map { |source| sources_manager.source_with_name_or_url(source) }
131
+ source = (sources_manager.code_source_list + podfile_sources).select do |s|
132
+ s.search(rspec.root.name)
133
+ end.first
134
+ end
135
+
136
+ spec_version = rspec.spec.version
137
+
138
+ raise Informative, "#{rspec.root.name}(#{spec_version})的podspec未找到,请执行 pod repo update 或添加相应的source源" unless source
139
+
140
+ UI.message "- 开始处理 #{rspec.spec.name}(#{spec_version}) 组件."
141
+
142
+ begin
143
+ # 从新 source 中获取 spec,在bin archive中会异常,因为找不到
144
+ specification = source.specification(rspec.root.name, spec_version)
145
+
146
+ raise Informative, "Specification of #{rspec.root.name}(#{spec_version}) is nil" unless specification
147
+
148
+ UI.message "#{rspec.root.name} #{spec_version} \r\n specification =#{specification} "
149
+ # 组件是 subspec
150
+ if rspec.spec.subspec?
151
+ specification = specification.subspec_by_name(rspec.name, false, true)
152
+ end
153
+ # 这里可能出现分析依赖的 source 和切换后的 source 对应 specification 的 subspec 对应不上
154
+ # 造成 subspec_by_name 返回 nil,这个是正常现象
155
+ next unless specification
156
+
157
+ used_by_only = if Pod.match_version?('~> 1.7')
158
+ rspec.used_by_non_library_targets_only
159
+ else
160
+ rspec.used_by_tests_only
161
+ end
162
+ # used_by_only = rspec.respond_to?(:used_by_tests_only) ? rspec.used_by_tests_only : rspec.used_by_non_library_targets_only
163
+ # 组装新的 rspec ,替换原 rspec
164
+ rspec = if Pod.match_version?('~> 1.4.0')
165
+ ResolverSpecification.new(specification, used_by_only)
166
+ else
167
+ ResolverSpecification.new(specification, used_by_only, source)
168
+ end
169
+ UI.message "组装新的 rspec ,替换原 rspec #{rspec.root.name} #{spec_version} \r\n specification =#{specification} \r\n #{rspec} "
170
+ rescue Pod::StandardError => e
171
+ # 没有从新的 source 找到对应版本组件,直接返回原 rspec
172
+ missing_binary_specs << rspec.spec if use_binary
173
+ # missing_binary_specs << rspec.spec
174
+ rspec
175
+ end
176
+ rspec
177
+ end.compact
178
+ end
179
+
180
+ if missing_binary_specs.any?
181
+ missing_binary_specs.uniq.each do |spec|
182
+ UI.message "【#{spec.name} | #{spec.version}】组件无对应二进制版本 , 将采用源码依赖."
183
+ end
184
+ # 下面的代码为了实现 auto 命令的 --all-make
185
+ Pod::Command::Bin::Archive.missing_binary_specs(missing_binary_specs)
186
+ #缓存没有二进制组件到spec文件,local_psec_dir 目录
187
+ sources_sepc = []
188
+ des_dir = CBin::Config::Builder.instance.local_psec_dir
189
+ FileUtils.rm_f(des_dir) if File.exist?des_dir
190
+ Dir.mkdir des_dir unless File.exist?des_dir
191
+ missing_binary_specs.uniq.each do |spec|
192
+ # 排除subspec
193
+ next if spec.name.include?('/')
194
+
195
+ spec_git_res = false
196
+ CBin::Config::Builder.instance.ignore_git_list.each do |ignore_git|
197
+ spec_git_res = spec.source[:git] && spec.source[:git].include?(ignore_git)
198
+ break if spec_git_res
199
+ end
200
+ next if spec_git_res
201
+
202
+ #获取没有制作二进制版本的spec集合
203
+ sources_sepc << spec
204
+ unless spec.defined_in_file.nil?
205
+ FileUtils.cp("#{spec.defined_in_file}", "#{des_dir}")
206
+ end
207
+ end
208
+ end
209
+
210
+ specs_by_target
211
+ end
212
+ end
213
+ end
214
+
215
+ if Pod.match_version?('~> 1.4.0')
216
+ # 1.4.0 没有 spec_source
217
+ class Specification
218
+ class Set
219
+ class LazySpecification < BasicObject
220
+ attr_reader :spec_source
221
+
222
+ old_initialize = instance_method(:initialize)
223
+ define_method(:initialize) do |name, version, source|
224
+ old_initialize.bind(self).call(name, version, source)
225
+
226
+ @spec_source = source
227
+ end
228
+
229
+ def respond_to?(method, include_all = false)
230
+ return super unless method == :spec_source
231
+
232
+ true
233
+ end
234
+ end
235
+ end
236
+ end
237
+ end
238
+ end
@@ -0,0 +1,34 @@
1
+
2
+
3
+ module Pod
4
+ class Installer
5
+ class Analyzer
6
+ class SandboxAnalyzer
7
+ # def pod_changed?(pod)
8
+ # spec = root_spec(pod)
9
+ # 有 subspec 的情况下,root spec 对应的 used_files 可能始终为空
10
+ # 要添加为空 && 没有 subspec 的情况
11
+ # file_accessors = spec.available_platforms.map { |platform| Sandbox::FileAccessor.new(sandbox.pod_dir(pod), spec.consumer(platform)) }
12
+ # files = [
13
+ # file_accessors.map(&:vendored_frameworks),
14
+ # file_accessors.map(&:vendored_libraries),
15
+ # file_accessors.map(&:resource_bundle_files),
16
+ # file_accessors.map(&:prefix_header),
17
+ # file_accessors.map(&:resources),
18
+ # file_accessors.map(&:source_files),
19
+ # file_accessors.map(&:module_map),
20
+ # ]
21
+ # used_files = files.flatten.compact.map(&:to_s).uniq
22
+ # p pod if used_files.empty?
23
+
24
+ # return true if spec.version != sandbox_version(pod)
25
+ # return true if spec.checksum != sandbox_checksum(pod)
26
+ # return true if resolved_spec_names(pod) != sandbox_spec_names(pod)
27
+ # return true if sandbox.predownloaded?(pod)
28
+ # return true if folder_empty?(pod)
29
+ # false
30
+ # end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+
2
+
3
+ require 'cocoapods'
4
+
5
+ module Pod
6
+ class Source
7
+ # Returns the path of the specification with the given name and version.
8
+ #
9
+ # @param [String] name
10
+ # the name of the Pod.
11
+ #
12
+ # @param [Version,String] version
13
+ # the version for the specification.
14
+ #
15
+ # @return [Pathname] The path of the specification.
16
+ #
17
+ def specification_path(name, version)
18
+ raise ArgumentError, 'No name' unless name
19
+ raise ArgumentError, 'No version' unless version
20
+
21
+ path = pod_path(name) + version.to_s
22
+
23
+ specification_path = Specification::VALID_EXTNAME
24
+ .map { |extname| "#{name}#{extname}" }
25
+ .map { |file| path + file }
26
+ .find(&:exist?)
27
+
28
+ unless specification_path
29
+ raise StandardError, "Unable to find the specification #{name} " \
30
+ "(#{version}) in the #{self.name} source."
31
+ end
32
+ specification_path
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+
2
+
3
+ require 'cocoapods'
4
+ require 'cocoapods-mtxx-bin/config/config'
5
+
6
+ module Pod
7
+ class Source
8
+ class Manager
9
+ # 源码 source list
10
+ def code_source_list
11
+ CBin.config.code_repo_url_list.split(";").map { |source| source_with_name_or_url(source)}
12
+ end
13
+ # 二进制 source
14
+ def binary_source
15
+ source_with_name_or_url(CBin.config.binary_repo_url)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+
2
+
3
+ require 'cocoapods-mtxx-bin/native/sources_manager'
4
+
5
+ module Pod
6
+ class Specification
7
+ VALID_EXTNAME = %w[.binary.podspec.json .binary.podspec .podspec.json .podspec].freeze
8
+ DEFAULT_TEMPLATE_EXTNAME = %w[.binary-template.podspec .binary-template.podspec.json].freeze
9
+
10
+ # TODO
11
+ # 可以在这里根据组件依赖二进制或源码调整 sources 的先后顺序
12
+ # 如果是源码,则调整 code_source 到最前面
13
+ # 如果是二进制,则调整 binary_source 到最前面
14
+ # 这样 CocoaPods 分析时,就会优先获取到对应源的 podspec
15
+ #
16
+ # 先要把 Podfile 里面的配置数据保存到单例中,再在这里判断,就不需要 resolver 了
17
+ # 但是现在这个插件依旧可用,重构需要时间 = = ,没什么动力去重构了呀。。。
18
+ #
19
+ # class Set
20
+ # old_initialize = instance_method(:initialize)
21
+ # define_method(:initialize) do |name, sources|
22
+ # if name == 'TDFAdaptationKit'
23
+ # sources_manager = Pod::Config.instance.sources_manager
24
+ # # sources = [sources_manager.binary_source, *sources].uniq
25
+ # sources = [sources_manager.code_source, *sources].uniq
26
+ # end
27
+ # old_initialize.bind(self).call(name, sources)
28
+ # end
29
+ # end
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ module Pod
2
+ class Installer
3
+ class Xcode
4
+ # The {Xcode::TargetValidator} ensures that the pod and aggregate target
5
+ # configuration is valid for installation.
6
+ #
7
+ class TargetValidator
8
+
9
+
10
+
11
+ def verify_swift_pods_have_module_dependencies
12
+ error_messages = []
13
+ pod_targets.each do |pod_target|
14
+ next unless pod_target.uses_swift?
15
+
16
+ non_module_dependencies = []
17
+ pod_target.dependent_targets.each do |dependent_target|
18
+ next if !dependent_target.should_build? || dependent_target.defines_module?
19
+ non_module_dependencies << dependent_target.name
20
+ end
21
+
22
+ next if non_module_dependencies.empty?
23
+
24
+ error_messages << "The Swift pod `#{pod_target.name}` depends upon #{non_module_dependencies.map { |d| "`#{d}`" }.to_sentence}, " \
25
+ "which #{non_module_dependencies.count == 1 ? 'does' : 'do'} not define modules. " \
26
+ 'To opt into those targets generating module maps '\
27
+ '(which is necessary to import them from Swift when building as static libraries), ' \
28
+ 'you may set `use_modular_headers!` globally in your Podfile, '\
29
+ 'or specify `:modular_headers => true` for particular dependencies.'
30
+ end
31
+ return false
32
+
33
+ # raise Informative, 'The following Swift pods cannot yet be integrated '\
34
+ # "as static libraries:\n\n#{error_messages.join("\n\n")}"
35
+ end
36
+
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+
2
+
3
+ module Pod
4
+ class Validator
5
+ # def validate_source_url(spec)
6
+ # return if spec.source.nil? || spec.source[:http].nil?
7
+ # url = URI(spec.source[:http])
8
+ # return if url.scheme == 'https' || url.scheme == 'file'
9
+ # warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPs protocol. " \
10
+ # 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\
11
+ # 'This will be an error in future releases. Please update the URL to use https.')
12
+ # end
13
+ #
14
+ # Perform analysis for a given spec (or subspec)
15
+ #
16
+ def perform_extensive_analysis(spec)
17
+ return true
18
+ end
19
+
20
+ #覆盖
21
+ def check_file_patterns
22
+ FILE_PATTERNS.each do |attr_name|
23
+ next if %i(source_files resources).include? attr_name
24
+ if respond_to?("_validate_#{attr_name}", true)
25
+ send("_validate_#{attr_name}")
26
+ else
27
+ validate_nonempty_patterns(attr_name, :error)
28
+ end
29
+ end
30
+
31
+ _validate_header_mappings_dir
32
+ if consumer.spec.root?
33
+ _validate_license
34
+ _validate_module_map
35
+ end
36
+ end
37
+
38
+ def validate_source_url(spec); end
39
+ end
40
+ end