cocoapods-fy-bin 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods-fy-bin/gem_version.rb +1 -1
- data/lib/cocoapods-fy-bin/native/201.rb +399 -0
- data/lib/cocoapods-fy-bin/native/225.rb +437 -0
- data/lib/cocoapods-fy-bin/native/installer.rb +2 -2
- data/lib/cocoapods-fy-bin/native/{pod_source_installer.rb → pod_source_downloader.rb} +6 -5
- data/lib/cocoapods-fy-bin/native/podfile_generator.rb +61 -66
- data/lib/cocoapods-fy-bin/native.rb +1 -1
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3372ff68d46f987c4e21891cdee83c6815cf0a7c2d27ff53a353af22dd16a203
|
4
|
+
data.tar.gz: d7e7a05736dec0d01c3df2d70235feac430ba0908f7329f0fc11e1bab2b0bc67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 229026f0d9bef89d24a9e8702a89f9238d2624a696f6b11487b12975d609289c57d6f83f2438f678f96347e883ae0254dc631a06e6aafd5bd9809d11580a5b05
|
7
|
+
data.tar.gz: 0c1ed328b142368b4039e5476382b6ea9599991d45afd9aa2454c11ca14cd9ea874d100a6a8faddf7a979a6ff975e65aed71d1865af5dda70eaa5c789b736c17
|
@@ -0,0 +1,399 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
module Generate
|
6
|
+
# Generates podfiles for pod specifications given a configuration.
|
7
|
+
#
|
8
|
+
class PodfileGenerator
|
9
|
+
# @return [Configuration]
|
10
|
+
# the configuration used when generating podfiles
|
11
|
+
#
|
12
|
+
attr_reader :configuration
|
13
|
+
|
14
|
+
def initialize(configuration)
|
15
|
+
@configuration = configuration
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Hash<Specification, Podfile>]
|
19
|
+
# a hash of specifications to generated podfiles
|
20
|
+
#
|
21
|
+
def podfiles_by_spec
|
22
|
+
Hash[configuration.podspecs.map do |spec|
|
23
|
+
[spec, podfile_for_spec(spec)]
|
24
|
+
end]
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Podfile] a podfile suitable for installing the given spec
|
28
|
+
#
|
29
|
+
# @param [Specification] spec
|
30
|
+
#
|
31
|
+
def podfile_for_spec(spec)
|
32
|
+
generator = self
|
33
|
+
dir = configuration.gen_dir_for_pod(spec.name)
|
34
|
+
project_name = configuration.project_name_for_spec(spec)
|
35
|
+
|
36
|
+
Pod::Podfile.new do
|
37
|
+
project "#{project_name}.xcodeproj"
|
38
|
+
workspace "#{spec.name}.xcworkspace"
|
39
|
+
|
40
|
+
plugin 'cocoapods-generate'
|
41
|
+
|
42
|
+
install! 'cocoapods', generator.installation_options
|
43
|
+
|
44
|
+
generator.podfile_plugins.each do |name, options|
|
45
|
+
plugin(*[name, options].compact)
|
46
|
+
end
|
47
|
+
|
48
|
+
use_frameworks!(generator.use_frameworks_value)
|
49
|
+
|
50
|
+
if (supported_swift_versions = generator.supported_swift_versions)
|
51
|
+
supports_swift_versions(supported_swift_versions)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Explicitly set sources
|
55
|
+
generator.configuration.sources.each do |source_url|
|
56
|
+
source(source_url)
|
57
|
+
end
|
58
|
+
|
59
|
+
self.defined_in_file = dir.join('CocoaPods.podfile.yaml')
|
60
|
+
|
61
|
+
test_specs = spec.recursive_subspecs.select(&:test_specification?)
|
62
|
+
app_specs = if spec.respond_to?(:app_specification?)
|
63
|
+
spec.recursive_subspecs.select(&:app_specification?)
|
64
|
+
else
|
65
|
+
[]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Stick all of the transitive dependencies in an abstract target.
|
69
|
+
# This allows us to force CocoaPods to use the versions / sources / external sources
|
70
|
+
# that we want.
|
71
|
+
# By using an abstract target,
|
72
|
+
abstract_target 'Transitive Dependencies' do
|
73
|
+
pods_for_transitive_dependencies = [spec.name]
|
74
|
+
.concat(test_specs.map(&:name))
|
75
|
+
.concat(test_specs.flat_map { |ts| ts.dependencies.flat_map(&:name) })
|
76
|
+
.concat(app_specs.map(&:name))
|
77
|
+
.concat(app_specs.flat_map { |as| as.dependencies.flat_map(&:name) })
|
78
|
+
|
79
|
+
dependencies = generator
|
80
|
+
.transitive_dependencies_by_pod
|
81
|
+
.values_at(*pods_for_transitive_dependencies)
|
82
|
+
.compact
|
83
|
+
.flatten(1)
|
84
|
+
.uniq
|
85
|
+
.sort_by(&:name)
|
86
|
+
.reject { |d| d.root_name == spec.root.name }
|
87
|
+
|
88
|
+
dependencies.each do |dependency|
|
89
|
+
pod_args = generator.pod_args_for_dependency(self, dependency)
|
90
|
+
pod(*pod_args)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Add platform-specific concrete targets that inherit the
|
95
|
+
# `pod` declaration for the local pod.
|
96
|
+
spec_platform_names = spec.available_platforms.map(&:string_name).flatten.each.reject do |platform_name|
|
97
|
+
!generator.configuration.platforms.nil? && !generator.configuration.platforms.include?(platform_name.downcase)
|
98
|
+
end
|
99
|
+
|
100
|
+
spec_platform_names.sort.each do |platform_name|
|
101
|
+
target "App-#{platform_name}" do
|
102
|
+
current_target_definition.swift_version = generator.swift_version if generator.swift_version
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# this block has to come _before_ inhibit_all_warnings! / use_modular_headers!,
|
107
|
+
# and the local `pod` declaration
|
108
|
+
current_target_definition.instance_exec do
|
109
|
+
transitive_dependencies = children.find { |c| c.name == 'Transitive Dependencies' }
|
110
|
+
|
111
|
+
%w[use_modular_headers inhibit_warnings].each do |key|
|
112
|
+
value = transitive_dependencies.send(:internal_hash).delete(key)
|
113
|
+
next if value.blank?
|
114
|
+
set_hash_value(key, value)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
inhibit_all_warnings! if generator.inhibit_all_warnings?
|
119
|
+
use_modular_headers! if generator.use_modular_headers?
|
120
|
+
|
121
|
+
# This is the pod declaration for the local pod,
|
122
|
+
# it will be inherited by the concrete target definitions below
|
123
|
+
pod_options = generator.dependency_compilation_kwargs(spec.name)
|
124
|
+
pod_options[:path] = spec.defined_in_file.relative_path_from(dir).to_s
|
125
|
+
{ testspecs: test_specs, appspecs: app_specs }.each do |key, specs|
|
126
|
+
pod_options[key] = specs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless specs.empty?
|
127
|
+
end
|
128
|
+
|
129
|
+
pod spec.name, **pod_options
|
130
|
+
|
131
|
+
# Implement local-sources option to set up dependencies to podspecs in the local filesystem.
|
132
|
+
next if generator.configuration.local_sources.empty?
|
133
|
+
generator.transitive_local_dependencies(spec, generator.configuration.local_sources).sort_by(&:first).each do |dependency, podspec_file|
|
134
|
+
pod_options = generator.dependency_compilation_kwargs(dependency.name)
|
135
|
+
pod_options[:path] = if podspec_file[0] == '/' # absolute path
|
136
|
+
podspec_file
|
137
|
+
else
|
138
|
+
'../../' + podspec_file
|
139
|
+
end
|
140
|
+
pod dependency.name, **pod_options
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def transitive_local_dependencies(spec, paths, found_podspecs: {}, include_non_library_subspecs: true)
|
146
|
+
if include_non_library_subspecs
|
147
|
+
non_library_specs = spec.recursive_subspecs.select do |ss|
|
148
|
+
ss.test_specification? || (ss.respond_to?(:app_specification?) && ss.app_specification?)
|
149
|
+
end
|
150
|
+
non_library_specs.each do |subspec|
|
151
|
+
transitive_local_dependencies(subspec, paths, found_podspecs: found_podspecs, include_non_library_subspecs: false)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
spec.dependencies.each do |dependency|
|
155
|
+
next if found_podspecs.key?(dependency)
|
156
|
+
found_podspec_file = nil
|
157
|
+
name = dependency.name.split('/')[0]
|
158
|
+
paths.each do |path|
|
159
|
+
podspec_file = File.join(path, name + '.podspec')
|
160
|
+
next unless File.file?(podspec_file)
|
161
|
+
found_podspec_file = podspec_file
|
162
|
+
break
|
163
|
+
end
|
164
|
+
next unless found_podspec_file
|
165
|
+
found_podspecs[dependency] = found_podspec_file.sub(%r{\A\./}, '')
|
166
|
+
transitive_local_dependencies(Pod::Specification.from_file(found_podspec_file), paths, found_podspecs: found_podspecs)
|
167
|
+
end
|
168
|
+
found_podspecs
|
169
|
+
end
|
170
|
+
|
171
|
+
# @return [Boolean]
|
172
|
+
# whether all warnings should be inhibited
|
173
|
+
#
|
174
|
+
def inhibit_all_warnings?
|
175
|
+
return false unless configuration.use_podfile?
|
176
|
+
target_definition_list.all? do |target_definition|
|
177
|
+
target_definition.send(:inhibit_warnings_hash)['all']
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# @return [Boolean]
|
182
|
+
# whether all pods should use modular headers
|
183
|
+
#
|
184
|
+
def use_modular_headers?
|
185
|
+
if configuration.use_podfile? && configuration.use_modular_headers?
|
186
|
+
raise Informative, 'Conflicting `use_modular_headers` option. Cannot specify both `--use-modular-headers` and `--use-podfile`.'
|
187
|
+
end
|
188
|
+
|
189
|
+
if configuration.use_podfile?
|
190
|
+
target_definition_list.all? do |target_definition|
|
191
|
+
target_definition.use_modular_headers_hash['all']
|
192
|
+
end
|
193
|
+
else
|
194
|
+
configuration.use_modular_headers?
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# @return [Boolean, Hash]
|
199
|
+
# the value to use for `use_frameworks!` DSL directive
|
200
|
+
#
|
201
|
+
def use_frameworks_value
|
202
|
+
return configuration.use_frameworks? unless configuration.use_podfile?
|
203
|
+
use_framework_values = target_definition_list.map do |target_definition|
|
204
|
+
if target_definition.respond_to?(:build_type) # CocoaPods >= 1.9
|
205
|
+
build_type = target_definition.build_type
|
206
|
+
if build_type.static_library?
|
207
|
+
false
|
208
|
+
else
|
209
|
+
{ linkage: build_type == BuildType.dynamic_framework ? :dynamic : :static }
|
210
|
+
end
|
211
|
+
else
|
212
|
+
target_definition.uses_frameworks?
|
213
|
+
end
|
214
|
+
end.uniq
|
215
|
+
raise Informative, 'Multiple use_frameworks! values detected in user Podfile.' unless use_framework_values.count == 1
|
216
|
+
use_framework_values.first
|
217
|
+
end
|
218
|
+
|
219
|
+
# @return [Hash]
|
220
|
+
# a hash with "compilation"-related dependency options for the `pod` DSL method
|
221
|
+
#
|
222
|
+
# @param [String] pod_name
|
223
|
+
#
|
224
|
+
def dependency_compilation_kwargs(pod_name)
|
225
|
+
options = {}
|
226
|
+
options[:inhibit_warnings] = inhibit_warnings?(pod_name) if inhibit_warnings?(pod_name) != inhibit_all_warnings?
|
227
|
+
options[:modular_headers] = modular_headers?(pod_name) if modular_headers?(pod_name) != use_modular_headers?
|
228
|
+
options
|
229
|
+
end
|
230
|
+
|
231
|
+
# @return [Hash<String,Array<Dependency>>]
|
232
|
+
# the transitive dependency objects dependency upon by each pod
|
233
|
+
#
|
234
|
+
def transitive_dependencies_by_pod
|
235
|
+
return {} unless configuration.use_lockfile?
|
236
|
+
@transitive_dependencies_by_pod ||= begin
|
237
|
+
lda = ::Pod::Installer::Analyzer::LockingDependencyAnalyzer
|
238
|
+
dependency_graph = Molinillo::DependencyGraph.new
|
239
|
+
configuration.lockfile.dependencies.each do |dependency|
|
240
|
+
dependency_graph.add_vertex(dependency.name, dependency, true)
|
241
|
+
end
|
242
|
+
add_to_dependency_graph = if lda.method(:add_to_dependency_graph).parameters.size == 4 # CocoaPods < 1.6.0
|
243
|
+
->(pod) { lda.add_to_dependency_graph(pod, [], dependency_graph, []) }
|
244
|
+
else
|
245
|
+
->(pod) { lda.add_to_dependency_graph(pod, [], dependency_graph, [], Set.new) }
|
246
|
+
end
|
247
|
+
configuration.lockfile.internal_data['PODS'].each(&add_to_dependency_graph)
|
248
|
+
|
249
|
+
transitive_dependencies_by_pod = Hash.new { |hash, key| hash[key] = [] }
|
250
|
+
dependency_graph.each do |v|
|
251
|
+
transitive_dependencies_by_pod[v.name].concat v.recursive_successors.map(&:payload) << v.payload
|
252
|
+
end
|
253
|
+
|
254
|
+
transitive_dependencies_by_pod.each_value(&:uniq!)
|
255
|
+
transitive_dependencies_by_pod
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# @return [Hash<String,Array<Dependency>>]
|
260
|
+
# dependencies in the podfile grouped by root name
|
261
|
+
#
|
262
|
+
def podfile_dependencies
|
263
|
+
return {} unless configuration.use_podfile?
|
264
|
+
@podfile_dependencies ||= configuration.podfile.dependencies.group_by(&:root_name).tap { |h| h.default = [] }
|
265
|
+
end
|
266
|
+
|
267
|
+
# @return [Hash<String,String>]
|
268
|
+
# versions in the lockfile keyed by pod name
|
269
|
+
#
|
270
|
+
def lockfile_versions
|
271
|
+
return {} unless configuration.use_lockfile_versions?
|
272
|
+
@lockfile_versions ||= Hash[configuration.lockfile.pod_names.map { |name| [name, "= #{configuration.lockfile.version(name)}"] }]
|
273
|
+
end
|
274
|
+
|
275
|
+
# @return [Hash<String,Array<Dependency>>]
|
276
|
+
# returns the arguments that should be passed to the Podfile DSL's
|
277
|
+
# `pod` method for the given podfile and dependency
|
278
|
+
#
|
279
|
+
# @param [Podfile] podfile
|
280
|
+
#
|
281
|
+
# @param [Dependency] dependency
|
282
|
+
#
|
283
|
+
def pod_args_for_dependency(podfile, dependency)
|
284
|
+
dependency = podfile_dependencies[dependency.root_name]
|
285
|
+
.map { |dep| dep.dup.tap { |d| d.name = dependency.name } }
|
286
|
+
.push(dependency)
|
287
|
+
.reduce(&:merge)
|
288
|
+
|
289
|
+
options = dependency_compilation_kwargs(dependency.name)
|
290
|
+
options[:source] = dependency.podspec_repo if dependency.podspec_repo
|
291
|
+
options.update(dependency.external_source) if dependency.external_source
|
292
|
+
%i[path podspec].each do |key|
|
293
|
+
next unless (path = options[key])
|
294
|
+
options[key] = Pathname(path)
|
295
|
+
.expand_path(configuration.podfile.defined_in_file.dirname)
|
296
|
+
.relative_path_from(podfile.defined_in_file.dirname)
|
297
|
+
.to_s
|
298
|
+
end
|
299
|
+
args = [dependency.name]
|
300
|
+
if dependency.external_source.nil?
|
301
|
+
requirements = dependency.requirement.as_list
|
302
|
+
if (version = lockfile_versions[dependency.name])
|
303
|
+
requirements << version
|
304
|
+
end
|
305
|
+
args.concat requirements.uniq
|
306
|
+
end
|
307
|
+
args << options unless options.empty?
|
308
|
+
args
|
309
|
+
end
|
310
|
+
|
311
|
+
def swift_version
|
312
|
+
@swift_version ||= target_definition_list.map(&:swift_version).compact.max
|
313
|
+
end
|
314
|
+
|
315
|
+
def supported_swift_versions
|
316
|
+
return unless configuration.use_podfile?
|
317
|
+
return if target_definition_list.empty?
|
318
|
+
return unless target_definition_list.first.respond_to?(:swift_version_requirements)
|
319
|
+
target_definition_list.reduce(nil) do |supported_swift_versions, target_definition|
|
320
|
+
target_swift_versions = target_definition.swift_version_requirements
|
321
|
+
next supported_swift_versions unless target_swift_versions
|
322
|
+
Array(target_swift_versions) | Array(supported_swift_versions)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
def installation_options
|
327
|
+
installation_options = {
|
328
|
+
deterministic_uuids: configuration.deterministic_uuids?,
|
329
|
+
share_schemes_for_development_pods: configuration.share_schemes_for_development_pods?,
|
330
|
+
warn_for_multiple_pod_sources: configuration.warn_for_multiple_pod_sources?
|
331
|
+
}
|
332
|
+
|
333
|
+
if Pod::Installer::InstallationOptions.all_options.include?('generate_multiple_pod_projects')
|
334
|
+
installation_options[:generate_multiple_pod_projects] = configuration.generate_multiple_pod_projects?
|
335
|
+
end
|
336
|
+
|
337
|
+
if Pod::Installer::InstallationOptions.all_options.include?('incremental_installation')
|
338
|
+
installation_options[:incremental_installation] = configuration.incremental_installation?
|
339
|
+
end
|
340
|
+
|
341
|
+
installation_options
|
342
|
+
end
|
343
|
+
|
344
|
+
def podfile_plugins
|
345
|
+
configuration.podfile_plugins.merge('cocoapods-disable-podfile-validations' => { 'no_abstract_only_pods' => true }) do |_key, old_value, new_value|
|
346
|
+
old_value.merge(new_value)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
private
|
351
|
+
|
352
|
+
# @return [Array<Podfile::TargetDefinition>]
|
353
|
+
# a list of all target definitions to consider from the podfile
|
354
|
+
#
|
355
|
+
def target_definition_list
|
356
|
+
return [] unless configuration.use_podfile?
|
357
|
+
@target_definition_list ||= begin
|
358
|
+
list = configuration.podfile.target_definition_list
|
359
|
+
list.reject!(&:abstract?) unless list.all?(&:abstract?)
|
360
|
+
list
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
# @return [Boolean]
|
365
|
+
# whether warnings should be inhibited for the given pod
|
366
|
+
#
|
367
|
+
# @param [String] pod_name
|
368
|
+
#
|
369
|
+
def inhibit_warnings?(pod_name)
|
370
|
+
return false unless configuration.use_podfile?
|
371
|
+
target_definitions_for_pod(pod_name).all? do |target_definition|
|
372
|
+
target_definition.inhibits_warnings_for_pod?(pod_name)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
# @return [Boolean]
|
377
|
+
# whether modular headers should be enabled for the given pod
|
378
|
+
#
|
379
|
+
# @param [String] pod_name
|
380
|
+
#
|
381
|
+
def modular_headers?(pod_name)
|
382
|
+
return true if configuration.use_modular_headers?
|
383
|
+
return false unless configuration.use_podfile?
|
384
|
+
target_definitions_for_pod(pod_name).all? do |target_definition|
|
385
|
+
target_definition.build_pod_as_module?(pod_name)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
# @return [Podfile::TargetDefinition]
|
390
|
+
#
|
391
|
+
# @param [String] pod_name
|
392
|
+
#
|
393
|
+
def target_definitions_for_pod(pod_name)
|
394
|
+
target_definitions = target_definition_list.reject { |td| td.dependencies.none? { |d| d.name == pod_name } }
|
395
|
+
target_definitions.empty? ? target_definition_list : target_definitions
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|
@@ -0,0 +1,437 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
module Generate
|
5
|
+
# Generates podfiles for pod specifications given a configuration.
|
6
|
+
#
|
7
|
+
class PodfileGenerator
|
8
|
+
# @return [Configuration]
|
9
|
+
# the configuration used when generating podfiles
|
10
|
+
#
|
11
|
+
attr_reader :configuration
|
12
|
+
|
13
|
+
def initialize(configuration)
|
14
|
+
@configuration = configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Hash<Array<Specification>, Podfile>] the podfiles keyed by the specs that are part of each.
|
18
|
+
#
|
19
|
+
def podfiles_by_specs
|
20
|
+
return { configuration.podspecs => podfile_for_specs(configuration.podspecs) } if configuration.single_workspace?
|
21
|
+
Hash[configuration.podspecs.map do |spec|
|
22
|
+
[[spec], podfile_for_specs([spec])]
|
23
|
+
end]
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Podfile] a podfile suitable for installing the given spec
|
27
|
+
#
|
28
|
+
# @param [Array<Specification>] specs
|
29
|
+
#
|
30
|
+
def podfile_for_specs(specs)
|
31
|
+
generator = self
|
32
|
+
dir = configuration.gen_dir_for_specs(specs)
|
33
|
+
project_name = configuration.project_name_for_specs(specs)
|
34
|
+
external_source_pods = configuration.external_source_pods
|
35
|
+
|
36
|
+
Pod::Podfile.new do
|
37
|
+
project "#{project_name}.xcodeproj"
|
38
|
+
workspace "#{project_name}.xcworkspace"
|
39
|
+
|
40
|
+
plugin 'cocoapods-generate'
|
41
|
+
|
42
|
+
install! 'cocoapods', generator.installation_options
|
43
|
+
|
44
|
+
generator.podfile_plugins.each do |name, options|
|
45
|
+
plugin(*[name, options].compact)
|
46
|
+
end
|
47
|
+
|
48
|
+
use_frameworks!(generator.use_frameworks_value)
|
49
|
+
|
50
|
+
if (supported_swift_versions = generator.supported_swift_versions)
|
51
|
+
supports_swift_versions(supported_swift_versions)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Explicitly set sources
|
55
|
+
generator.configuration.sources.each do |source_url|
|
56
|
+
source(source_url)
|
57
|
+
end
|
58
|
+
|
59
|
+
self.defined_in_file = dir.join('CocoaPods.podfile.yaml')
|
60
|
+
|
61
|
+
test_specs_by_spec = Hash[specs.map do |spec|
|
62
|
+
[spec, spec.recursive_subspecs.select(&:test_specification?)]
|
63
|
+
end]
|
64
|
+
app_specs_by_spec = Hash[specs.map do |spec|
|
65
|
+
app_specs = if spec.respond_to?(:app_specification?)
|
66
|
+
spec.recursive_subspecs.select(&:app_specification?)
|
67
|
+
else
|
68
|
+
[]
|
69
|
+
end
|
70
|
+
[spec, app_specs]
|
71
|
+
end]
|
72
|
+
|
73
|
+
# Stick all of the transitive dependencies in an abstract target.
|
74
|
+
# This allows us to force CocoaPods to use the versions / sources / external sources
|
75
|
+
# that we want.
|
76
|
+
abstract_target 'Transitive Dependencies' do
|
77
|
+
pods_for_transitive_dependencies = specs.flat_map do |spec|
|
78
|
+
[spec.name]
|
79
|
+
.concat(test_specs_by_spec.keys.map(&:name))
|
80
|
+
.concat(test_specs_by_spec.values.flatten.flat_map { |ts| ts.dependencies.flat_map(&:name) })
|
81
|
+
.concat(app_specs_by_spec.keys.map(&:name))
|
82
|
+
.concat(app_specs_by_spec.values.flatten.flat_map { |as| as.dependencies.flat_map(&:name) })
|
83
|
+
end
|
84
|
+
pods_for_transitive_dependencies.uniq!
|
85
|
+
|
86
|
+
spec_names = specs.map { |s| s.root.name }.to_set
|
87
|
+
dependencies = generator
|
88
|
+
.transitive_dependencies_by_pod
|
89
|
+
.values_at(*pods_for_transitive_dependencies)
|
90
|
+
.compact
|
91
|
+
.flatten(1)
|
92
|
+
.uniq
|
93
|
+
.sort_by(&:name)
|
94
|
+
.reject { |d| spec_names.include?(d.root_name) }
|
95
|
+
|
96
|
+
dependencies.each do |dependency|
|
97
|
+
pod_args = generator.pod_args_for_podfile_dependency(self, dependency)
|
98
|
+
pod(*pod_args)
|
99
|
+
end
|
100
|
+
|
101
|
+
external_source_pods.each do |hash|
|
102
|
+
hash.each do |name, attrs|
|
103
|
+
next if spec_names.include?(name)
|
104
|
+
|
105
|
+
dependency = Dependency.new(name, attrs.first.deep_symbolize_keys)
|
106
|
+
pod_args = generator.pod_args_for_dependency(nil, dependency)
|
107
|
+
pod(*pod_args)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Add platform-specific concrete targets that inherit the `pod` declaration for the local pod.
|
113
|
+
spec_platform_names = specs.flat_map { |s| s.available_platforms.map(&:string_name) }.uniq.each.reject do |platform_name|
|
114
|
+
!generator.configuration.platforms.nil? && !generator.configuration.platforms.include?(platform_name.downcase)
|
115
|
+
end
|
116
|
+
|
117
|
+
spec_platform_names.sort.each do |platform_name|
|
118
|
+
target "App-#{platform_name}" do
|
119
|
+
current_target_definition.swift_version = generator.swift_version if generator.swift_version
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# this block has to come _before_ inhibit_all_warnings! / use_modular_headers!,
|
124
|
+
# and the local `pod` declaration
|
125
|
+
current_target_definition.instance_exec do
|
126
|
+
transitive_dependencies = children.find { |c| c.name == 'Transitive Dependencies' }
|
127
|
+
|
128
|
+
%w[use_modular_headers inhibit_warnings].each do |key|
|
129
|
+
value = transitive_dependencies.send(:internal_hash).delete(key)
|
130
|
+
next if value.blank?
|
131
|
+
set_hash_value(key, value)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
inhibit_all_warnings! if generator.inhibit_all_warnings?
|
136
|
+
use_modular_headers! if generator.use_modular_headers?
|
137
|
+
|
138
|
+
specs.each do |spec|
|
139
|
+
# This is the pod declaration for the local pod,
|
140
|
+
# it will be inherited by the concrete target definitions below
|
141
|
+
pod_options = generator.dependency_compilation_kwargs(spec.name)
|
142
|
+
|
143
|
+
path = spec.defined_in_file.relative_path_from(dir).to_s
|
144
|
+
pod_options[:path] = path
|
145
|
+
{ testspecs: test_specs_by_spec[spec], appspecs: app_specs_by_spec[spec] }.each do |key, subspecs|
|
146
|
+
pod_options[key] = subspecs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless subspecs.blank?
|
147
|
+
end
|
148
|
+
pod spec.name, **pod_options
|
149
|
+
end
|
150
|
+
|
151
|
+
# Implement local-sources option to set up dependencies to podspecs in the local filesystem.
|
152
|
+
next if generator.configuration.local_sources.empty?
|
153
|
+
specs.each do |spec|
|
154
|
+
generator.transitive_local_dependencies(spec, generator.configuration.local_sources).sort_by(&:first).each do |dependency, podspec_file|
|
155
|
+
pod_options = generator.dependency_compilation_kwargs(dependency.name)
|
156
|
+
pod_options[:path] = if podspec_file[0] == '/' # absolute path
|
157
|
+
podspec_file
|
158
|
+
else
|
159
|
+
'../../' + podspec_file
|
160
|
+
end
|
161
|
+
pod dependency.name, **pod_options
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def transitive_local_dependencies(spec, paths, found_podspecs: {}, include_non_library_subspecs: true)
|
168
|
+
if include_non_library_subspecs
|
169
|
+
non_library_specs = spec.recursive_subspecs.select do |ss|
|
170
|
+
ss.test_specification? || (ss.respond_to?(:app_specification?) && ss.app_specification?)
|
171
|
+
end
|
172
|
+
non_library_specs.each do |subspec|
|
173
|
+
transitive_local_dependencies(subspec, paths, found_podspecs: found_podspecs, include_non_library_subspecs: false)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
spec.dependencies.each do |dependency|
|
177
|
+
next if found_podspecs.key?(dependency)
|
178
|
+
found_podspec_file = nil
|
179
|
+
name = dependency.name.split('/')[0]
|
180
|
+
paths.each do |path|
|
181
|
+
podspec_file = File.join(path, name + '.podspec')
|
182
|
+
next unless File.file?(podspec_file)
|
183
|
+
found_podspec_file = podspec_file
|
184
|
+
break
|
185
|
+
end
|
186
|
+
next unless found_podspec_file
|
187
|
+
found_podspecs[dependency] = found_podspec_file.sub(%r{\A\./}, '')
|
188
|
+
transitive_local_dependencies(Pod::Specification.from_file(found_podspec_file), paths, found_podspecs: found_podspecs)
|
189
|
+
end
|
190
|
+
found_podspecs
|
191
|
+
end
|
192
|
+
|
193
|
+
# @return [Boolean]
|
194
|
+
# whether all warnings should be inhibited
|
195
|
+
#
|
196
|
+
def inhibit_all_warnings?
|
197
|
+
return false unless configuration.use_podfile?
|
198
|
+
target_definition_list.all? do |target_definition|
|
199
|
+
target_definition.send(:inhibit_warnings_hash)['all']
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# @return [Boolean]
|
204
|
+
# whether all pods should use modular headers
|
205
|
+
#
|
206
|
+
def use_modular_headers?
|
207
|
+
if configuration.use_podfile? && configuration.use_modular_headers?
|
208
|
+
raise Informative, 'Conflicting `use_modular_headers` option. Cannot specify both `--use-modular-headers` and `--use-podfile`.'
|
209
|
+
end
|
210
|
+
|
211
|
+
if configuration.use_podfile?
|
212
|
+
target_definition_list.all? do |target_definition|
|
213
|
+
target_definition.use_modular_headers_hash['all']
|
214
|
+
end
|
215
|
+
else
|
216
|
+
configuration.use_modular_headers?
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
# @return [Boolean, Hash]
|
221
|
+
# the value to use for `use_frameworks!` DSL directive
|
222
|
+
#
|
223
|
+
def use_frameworks_value
|
224
|
+
return configuration.use_frameworks? unless configuration.use_podfile?
|
225
|
+
use_framework_values = target_definition_list.map do |target_definition|
|
226
|
+
if target_definition.respond_to?(:build_type) # CocoaPods >= 1.9
|
227
|
+
build_type = target_definition.build_type
|
228
|
+
if build_type.static_library?
|
229
|
+
false
|
230
|
+
else
|
231
|
+
{ linkage: build_type == BuildType.dynamic_framework ? :dynamic : :static }
|
232
|
+
end
|
233
|
+
else
|
234
|
+
target_definition.uses_frameworks?
|
235
|
+
end
|
236
|
+
end.uniq
|
237
|
+
raise Informative, 'Multiple use_frameworks! values detected in user Podfile.' unless use_framework_values.count == 1
|
238
|
+
use_framework_values.first
|
239
|
+
end
|
240
|
+
|
241
|
+
# @return [Hash]
|
242
|
+
# a hash with "compilation"-related dependency options for the `pod` DSL method
|
243
|
+
#
|
244
|
+
# @param [String] pod_name
|
245
|
+
#
|
246
|
+
def dependency_compilation_kwargs(pod_name)
|
247
|
+
options = {}
|
248
|
+
options[:inhibit_warnings] = inhibit_warnings?(pod_name) if inhibit_warnings?(pod_name) != inhibit_all_warnings?
|
249
|
+
options[:modular_headers] = modular_headers?(pod_name) if modular_headers?(pod_name) != use_modular_headers?
|
250
|
+
options
|
251
|
+
end
|
252
|
+
|
253
|
+
# @return [Hash<String,Array<Dependency>>]
|
254
|
+
# the transitive dependency objects dependency upon by each pod
|
255
|
+
#
|
256
|
+
def transitive_dependencies_by_pod
|
257
|
+
return {} unless configuration.use_lockfile?
|
258
|
+
@transitive_dependencies_by_pod ||= begin
|
259
|
+
lda = ::Pod::Installer::Analyzer::LockingDependencyAnalyzer
|
260
|
+
dependency_graph = Molinillo::DependencyGraph.new
|
261
|
+
configuration.lockfile.dependencies.each do |dependency|
|
262
|
+
dependency_graph.add_vertex(dependency.name, dependency, true)
|
263
|
+
end
|
264
|
+
add_to_dependency_graph = if lda.method(:add_to_dependency_graph).parameters.size == 4 # CocoaPods < 1.6.0
|
265
|
+
->(pod) { lda.add_to_dependency_graph(pod, [], dependency_graph, []) }
|
266
|
+
else
|
267
|
+
->(pod) { lda.add_to_dependency_graph(pod, [], dependency_graph, [], Set.new) }
|
268
|
+
end
|
269
|
+
configuration.lockfile.internal_data['PODS'].each(&add_to_dependency_graph)
|
270
|
+
|
271
|
+
transitive_dependencies_by_pod = Hash.new { |hash, key| hash[key] = [] }
|
272
|
+
dependency_graph.each do |v|
|
273
|
+
transitive_dependencies_by_pod[v.name].concat v.recursive_successors.map(&:payload) << v.payload
|
274
|
+
end
|
275
|
+
|
276
|
+
transitive_dependencies_by_pod.each_value(&:uniq!)
|
277
|
+
transitive_dependencies_by_pod
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
# @return [Hash<String,Array<Dependency>>]
|
282
|
+
# dependencies in the podfile grouped by root name
|
283
|
+
#
|
284
|
+
def podfile_dependencies
|
285
|
+
return {} unless configuration.use_podfile?
|
286
|
+
@podfile_dependencies ||= configuration.podfile.dependencies.group_by(&:root_name).tap { |h| h.default = [] }
|
287
|
+
end
|
288
|
+
|
289
|
+
# @return [Hash<String,String>]
|
290
|
+
# versions in the lockfile keyed by pod name
|
291
|
+
#
|
292
|
+
def lockfile_versions
|
293
|
+
return {} unless configuration.use_lockfile_versions?
|
294
|
+
@lockfile_versions ||= Hash[configuration.lockfile.pod_names.map { |name| [name, "= #{configuration.lockfile.version(name)}"] }]
|
295
|
+
end
|
296
|
+
|
297
|
+
# @return [Hash<String,Array<Dependency>>]
|
298
|
+
# returns the arguments that should be passed to the Podfile DSL's
|
299
|
+
# `pod` method for the given podfile and dependency
|
300
|
+
#
|
301
|
+
# @param [Podfile] podfile
|
302
|
+
#
|
303
|
+
# @param [Dependency] dependency
|
304
|
+
#
|
305
|
+
def pod_args_for_podfile_dependency(podfile, dependency)
|
306
|
+
dependency = podfile_dependencies[dependency.root_name]
|
307
|
+
.map { |dep| dep.dup.tap { |d| d.name = dependency.name } }
|
308
|
+
.push(dependency)
|
309
|
+
.reduce(&:merge)
|
310
|
+
pod_args_for_dependency(podfile, dependency)
|
311
|
+
end
|
312
|
+
|
313
|
+
# @return [Hash<String,Array<Dependency>>]
|
314
|
+
# returns the arguments that should be passed to the Podfile DSL's
|
315
|
+
# `pod` method.
|
316
|
+
#
|
317
|
+
# @param [Podfile] podfile
|
318
|
+
#
|
319
|
+
# @param [Dependency] dependency
|
320
|
+
#
|
321
|
+
def pod_args_for_dependency(podfile, dependency)
|
322
|
+
options = dependency_compilation_kwargs(dependency.name)
|
323
|
+
options[:source] = dependency.podspec_repo if dependency.podspec_repo
|
324
|
+
options.update(dependency.external_source) if dependency.external_source
|
325
|
+
%i[path podspec].each do |key|
|
326
|
+
next unless (path = options[key])
|
327
|
+
options[key] = Pathname(path)
|
328
|
+
.expand_path(configuration.podfile.defined_in_file.dirname)
|
329
|
+
.relative_path_from(podfile.defined_in_file.dirname)
|
330
|
+
.to_s
|
331
|
+
end
|
332
|
+
args = [dependency.name]
|
333
|
+
if dependency.external_source.nil?
|
334
|
+
requirements = dependency.requirement.as_list
|
335
|
+
if (version = lockfile_versions[dependency.name])
|
336
|
+
requirements << version
|
337
|
+
end
|
338
|
+
args.concat requirements.uniq
|
339
|
+
end
|
340
|
+
args << options unless options.empty?
|
341
|
+
args
|
342
|
+
end
|
343
|
+
|
344
|
+
def swift_version
|
345
|
+
@swift_version ||= target_definition_list.map(&:swift_version).compact.max
|
346
|
+
end
|
347
|
+
|
348
|
+
def supported_swift_versions
|
349
|
+
return unless configuration.use_podfile?
|
350
|
+
return if target_definition_list.empty?
|
351
|
+
return unless target_definition_list.first.respond_to?(:swift_version_requirements)
|
352
|
+
target_definition_list.reduce(nil) do |supported_swift_versions, target_definition|
|
353
|
+
target_swift_versions = target_definition.swift_version_requirements
|
354
|
+
next supported_swift_versions unless target_swift_versions
|
355
|
+
Array(target_swift_versions) | Array(supported_swift_versions)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def installation_options
|
360
|
+
installation_options = {
|
361
|
+
deterministic_uuids: configuration.deterministic_uuids?,
|
362
|
+
share_schemes_for_development_pods: configuration.share_schemes_for_development_pods,
|
363
|
+
warn_for_multiple_pod_sources: configuration.warn_for_multiple_pod_sources?
|
364
|
+
}
|
365
|
+
|
366
|
+
if Pod::Installer::InstallationOptions.all_options.include?('generate_multiple_pod_projects')
|
367
|
+
installation_options[:generate_multiple_pod_projects] = configuration.generate_multiple_pod_projects?
|
368
|
+
end
|
369
|
+
|
370
|
+
if Pod::Installer::InstallationOptions.all_options.include?('incremental_installation')
|
371
|
+
installation_options[:incremental_installation] = configuration.incremental_installation?
|
372
|
+
end
|
373
|
+
|
374
|
+
if Pod::Installer::InstallationOptions.all_options.include?('disable_input_output_paths')
|
375
|
+
installation_options[:disable_input_output_paths] = configuration.disable_input_output_paths
|
376
|
+
end
|
377
|
+
|
378
|
+
installation_options
|
379
|
+
end
|
380
|
+
|
381
|
+
def podfile_plugins
|
382
|
+
configuration.podfile_plugins.merge('cocoapods-disable-podfile-validations' => { 'no_abstract_only_pods' => true }) do |_key, old_value, new_value|
|
383
|
+
old_value.merge(new_value)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
private
|
388
|
+
|
389
|
+
# @return [Array<Podfile::TargetDefinition>]
|
390
|
+
# a list of all target definitions to consider from the podfile
|
391
|
+
#
|
392
|
+
def target_definition_list
|
393
|
+
return [] unless configuration.use_podfile?
|
394
|
+
@target_definition_list ||= begin
|
395
|
+
list = configuration.podfile.target_definition_list
|
396
|
+
list.reject!(&:abstract?) unless list.all?(&:abstract?)
|
397
|
+
list
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
# @return [Boolean]
|
402
|
+
# whether warnings should be inhibited for the given pod
|
403
|
+
#
|
404
|
+
# @param [String] pod_name
|
405
|
+
#
|
406
|
+
def inhibit_warnings?(pod_name)
|
407
|
+
return false unless configuration.use_podfile?
|
408
|
+
target_definitions_for_pod(pod_name).all? do |target_definition|
|
409
|
+
target_definition.inhibits_warnings_for_pod?(pod_name)
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
# @return [Boolean]
|
414
|
+
# whether modular headers should be enabled for the given pod
|
415
|
+
#
|
416
|
+
# @param [String] pod_name
|
417
|
+
#
|
418
|
+
def modular_headers?(pod_name)
|
419
|
+
return true if configuration.use_modular_headers?
|
420
|
+
return false unless configuration.use_podfile?
|
421
|
+
target_definitions_for_pod(pod_name).all? do |target_definition|
|
422
|
+
target_definition.build_pod_as_module?(pod_name)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
# @return [Podfile::TargetDefinition]
|
427
|
+
#
|
428
|
+
# @param [String] pod_name
|
429
|
+
#
|
430
|
+
def target_definitions_for_pod(pod_name)
|
431
|
+
target_definitions = target_definition_list.reject { |td| td.dependencies.none? { |d| d.name == pod_name } }
|
432
|
+
target_definitions.empty? ? target_definition_list : target_definitions
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
@@ -2,7 +2,7 @@ require 'cocoapods/installer/project_cache/target_metadata.rb'
|
|
2
2
|
require 'parallel'
|
3
3
|
require 'cocoapods'
|
4
4
|
require 'xcodeproj'
|
5
|
-
require 'cocoapods-fy-bin/native/
|
5
|
+
require 'cocoapods-fy-bin/native/pod_source_downloader'
|
6
6
|
require 'cocoapods-fy-bin/config/config'
|
7
7
|
|
8
8
|
module Pod
|
@@ -74,7 +74,7 @@ module Pod
|
|
74
74
|
alias old_create_pod_installer create_pod_installer
|
75
75
|
def create_pod_installer(pod_name)
|
76
76
|
installer = old_create_pod_installer(pod_name)
|
77
|
-
installer.installation_options = installation_options
|
77
|
+
# installer.installation_options = installation_options
|
78
78
|
installer
|
79
79
|
end
|
80
80
|
|
@@ -1,19 +1,20 @@
|
|
1
1
|
|
2
|
-
|
3
2
|
require 'cocoapods-fy-bin/native/installation_options'
|
4
3
|
|
5
4
|
module Pod
|
6
5
|
class Installer
|
7
|
-
|
6
|
+
# cocoapods 把方法迁移到 PodSourceDownloader
|
7
|
+
# class PodSourceInstaller
|
8
|
+
class PodSourceDownloader
|
8
9
|
attr_accessor :installation_options
|
9
10
|
|
10
11
|
alias old_verify_source_is_secure verify_source_is_secure
|
11
12
|
def verify_source_is_secure(root_spec)
|
12
13
|
# http source 默认不警告
|
13
|
-
if installation_options.warn_for_unsecure_source?
|
14
|
+
# if installation_options.warn_for_unsecure_source?
|
14
15
|
old_verify_source_is_secure(root_spec)
|
15
|
-
end
|
16
|
+
# end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
19
|
-
end
|
20
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'parallel'
|
4
4
|
require 'cocoapods'
|
5
|
-
require 'cocoapods-fy-bin/native/
|
5
|
+
require 'cocoapods-fy-bin/native/pod_source_downloader'
|
6
6
|
|
7
7
|
|
8
8
|
require 'parallel'
|
@@ -17,15 +17,17 @@ module Pod
|
|
17
17
|
#
|
18
18
|
# @param [Specification] spec
|
19
19
|
#
|
20
|
-
alias old_podfile_for_spec
|
20
|
+
alias old_podfile_for_spec podfile_for_specs
|
21
21
|
|
22
|
-
def
|
22
|
+
def podfile_for_specs(specs)
|
23
23
|
generator = self
|
24
|
-
dir = configuration.
|
24
|
+
dir = configuration.gen_dir_for_specs(specs)
|
25
|
+
project_name = configuration.project_name_for_specs(specs)
|
26
|
+
# external_source_pods = configuration.external_source_pods
|
25
27
|
|
26
28
|
Pod::Podfile.new do
|
27
|
-
project "#{
|
28
|
-
workspace "#{
|
29
|
+
project "#{project_name}.xcodeproj"
|
30
|
+
workspace "#{project_name}.xcworkspace"
|
29
31
|
|
30
32
|
plugin 'cocoapods-generate'
|
31
33
|
|
@@ -35,7 +37,7 @@ module Pod
|
|
35
37
|
plugin(*[name, options].compact)
|
36
38
|
end
|
37
39
|
|
38
|
-
use_frameworks!(generator.
|
40
|
+
use_frameworks!(generator.use_frameworks_value)
|
39
41
|
|
40
42
|
if (supported_swift_versions = generator.supported_swift_versions)
|
41
43
|
supports_swift_versions(supported_swift_versions)
|
@@ -48,12 +50,17 @@ module Pod
|
|
48
50
|
|
49
51
|
self.defined_in_file = dir.join('CocoaPods.podfile.yaml')
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
test_specs_by_spec = Hash[specs.map do |spec|
|
54
|
+
[spec, spec.recursive_subspecs.select(&:test_specification?)]
|
55
|
+
end]
|
56
|
+
app_specs_by_spec = Hash[specs.map do |spec|
|
57
|
+
app_specs = if spec.respond_to?(:app_specification?)
|
58
|
+
spec.recursive_subspecs.select(&:app_specification?)
|
59
|
+
else
|
60
|
+
[]
|
61
|
+
end
|
62
|
+
[spec, app_specs]
|
63
|
+
end]
|
57
64
|
|
58
65
|
# Stick all of the transitive dependencies in an abstract target.
|
59
66
|
# This allows us to force CocoaPods to use the versions / sources / external sources
|
@@ -62,30 +69,43 @@ module Pod
|
|
62
69
|
|
63
70
|
# 会导致多个dependencies出现, 注释by slj
|
64
71
|
# abstract_target 'Transitive Dependencies' do
|
65
|
-
# pods_for_transitive_dependencies =
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
72
|
+
# pods_for_transitive_dependencies = specs.flat_map do |spec|
|
73
|
+
# [spec.name]
|
74
|
+
# .concat(test_specs_by_spec.keys.map(&:name))
|
75
|
+
# .concat(test_specs_by_spec.values.flatten.flat_map { |ts| ts.dependencies.flat_map(&:name) })
|
76
|
+
# .concat(app_specs_by_spec.keys.map(&:name))
|
77
|
+
# .concat(app_specs_by_spec.values.flatten.flat_map { |as| as.dependencies.flat_map(&:name) })
|
78
|
+
# end
|
79
|
+
# pods_for_transitive_dependencies.uniq!
|
70
80
|
#
|
81
|
+
# spec_names = specs.map { |s| s.root.name }.to_set
|
71
82
|
# dependencies = generator
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
83
|
+
# .transitive_dependencies_by_pod
|
84
|
+
# .values_at(*pods_for_transitive_dependencies)
|
85
|
+
# .compact
|
86
|
+
# .flatten(1)
|
87
|
+
# .uniq
|
88
|
+
# .sort_by(&:name)
|
89
|
+
# .reject { |d| spec_names.include?(d.root_name) }
|
79
90
|
#
|
80
91
|
# dependencies.each do |dependency|
|
81
|
-
# pod_args = generator.
|
92
|
+
# pod_args = generator.pod_args_for_podfile_dependency(self, dependency)
|
82
93
|
# pod(*pod_args)
|
83
94
|
# end
|
95
|
+
#
|
96
|
+
# external_source_pods.each do |hash|
|
97
|
+
# hash.each do |name, attrs|
|
98
|
+
# next if spec_names.include?(name)
|
99
|
+
#
|
100
|
+
# dependency = Dependency.new(name, attrs.first.deep_symbolize_keys)
|
101
|
+
# pod_args = generator.pod_args_for_dependency(nil, dependency)
|
102
|
+
# pod(*pod_args)
|
103
|
+
# end
|
104
|
+
# end
|
84
105
|
# end
|
85
106
|
|
86
|
-
# Add platform-specific concrete targets that inherit the
|
87
|
-
|
88
|
-
spec_platform_names = spec.available_platforms.map(&:string_name).flatten.each.reject do |platform_name|
|
107
|
+
# Add platform-specific concrete targets that inherit the `pod` declaration for the local pod.
|
108
|
+
spec_platform_names = specs.flat_map { |s| s.available_platforms.map(&:string_name) }.uniq.each.reject do |platform_name|
|
89
109
|
!generator.configuration.platforms.nil? && !generator.configuration.platforms.include?(platform_name.downcase)
|
90
110
|
end
|
91
111
|
|
@@ -103,25 +123,24 @@ module Pod
|
|
103
123
|
inhibit_all_warnings! if generator.inhibit_all_warnings?
|
104
124
|
use_modular_headers! if generator.use_modular_headers?
|
105
125
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
pod_options[:path] = spec.defined_in_file.relative_path_from(dir).to_s
|
111
|
-
# generator.configuration.podfile.dependencies[0].external_source
|
126
|
+
specs.each do |spec|
|
127
|
+
# This is the pod declaration for the local pod,
|
128
|
+
# it will be inherited by the concrete target definitions below
|
129
|
+
pod_options = generator.dependency_compilation_kwargs(spec.name)
|
112
130
|
|
113
|
-
|
114
|
-
|
115
|
-
|
131
|
+
path = spec.defined_in_file.relative_path_from(dir).to_s
|
132
|
+
pod_options[:path] = path
|
133
|
+
{ testspecs: test_specs_by_spec[spec], appspecs: app_specs_by_spec[spec] }.each do |key, subspecs|
|
134
|
+
pod_options[key] = subspecs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless subspecs.blank?
|
135
|
+
end
|
136
|
+
pod spec.name, **pod_options
|
116
137
|
end
|
117
138
|
|
118
|
-
pod spec.name, **pod_options
|
119
|
-
|
120
139
|
if Pod::Config.instance.podfile
|
121
140
|
target_definitions['Pods'].instance_exec do
|
122
141
|
target_definition = nil
|
123
142
|
Pod::Config.instance.podfile.target_definition_list.each do |target|
|
124
|
-
if target.label == "Pods-#{
|
143
|
+
if target.label == "Pods-#{project_name}"
|
125
144
|
target_definition = target
|
126
145
|
break
|
127
146
|
end
|
@@ -139,7 +158,7 @@ module Pod
|
|
139
158
|
next if value.blank?
|
140
159
|
#删除 本地库中的 spec.name,因为本地的./spec.name地址是错的
|
141
160
|
value.each do |f|
|
142
|
-
if f.is_a?(Hash) && f.keys.first ==
|
161
|
+
if f.is_a?(Hash) && f.keys.first == project_name
|
143
162
|
value.delete f
|
144
163
|
break
|
145
164
|
end
|
@@ -152,34 +171,10 @@ module Pod
|
|
152
171
|
value = target_definition.to_hash['configuration_pod_whitelist']
|
153
172
|
next if value.blank?
|
154
173
|
set_hash_value(%w(configuration_pod_whitelist).first, value)
|
155
|
-
|
156
|
-
|
157
174
|
end
|
158
|
-
|
159
|
-
|
160
175
|
end
|
161
|
-
|
162
176
|
end
|
163
177
|
|
164
|
-
# if generator.configuration && generator.configuration.podfile
|
165
|
-
# #变量本地podfile下的dependencies 写入新的验证文件中,指定依赖源
|
166
|
-
# generator.configuration.podfile.dependencies.each { |dependencies|
|
167
|
-
# #如果不存在dependencies.external_source,就不变量
|
168
|
-
# next unless dependencies.external_source
|
169
|
-
#
|
170
|
-
# dependencies.external_source.each { |key_d, value|
|
171
|
-
# pod_options = generator.dependency_compilation_kwargs(dependencies.name)
|
172
|
-
# pod_options[key_d] = value.to_s
|
173
|
-
# { testspecs: test_specs, appspecs: app_specs }.each do |key, specs|
|
174
|
-
# pod_options[key] = specs.map { |s| s.name.sub(%r{^#{Regexp.escape spec.root.name}/}, '') }.sort unless specs.empty?
|
175
|
-
# end
|
176
|
-
# # 过滤 dependencies.name == spec.name
|
177
|
-
# pod(dependencies.name, **pod_options) unless dependencies.name == spec.name
|
178
|
-
# }
|
179
|
-
# }
|
180
|
-
# end
|
181
|
-
|
182
|
-
|
183
178
|
# Implement local-sources option to set up dependencies to podspecs in the local filesystem.
|
184
179
|
next if generator.configuration.local_sources.empty?
|
185
180
|
generator.transitive_local_dependencies(spec, generator.configuration.local_sources).each do |dependency, podspec_file|
|
@@ -8,7 +8,7 @@ if Pod.match_version?('~> 1.4')
|
|
8
8
|
require 'cocoapods-fy-bin/native/analyzer'
|
9
9
|
require 'cocoapods-fy-bin/native/installer'
|
10
10
|
require 'cocoapods-fy-bin/native/podfile_generator'
|
11
|
-
require 'cocoapods-fy-bin/native/
|
11
|
+
require 'cocoapods-fy-bin/native/pod_source_downloader'
|
12
12
|
require 'cocoapods-fy-bin/native/linter'
|
13
13
|
require 'cocoapods-fy-bin/native/resolver'
|
14
14
|
require 'cocoapods-fy-bin/native/source'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-fy-bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|
@@ -38,20 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 7.0.8
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 7.0.8
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: cocoapods-generate
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - '='
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
61
|
+
version: 2.2.5
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - '='
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
68
|
+
version: 2.2.5
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rest-client
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,6 +149,8 @@ files:
|
|
135
149
|
- lib/cocoapods-fy-bin/helpers/spec_source_creator.rb
|
136
150
|
- lib/cocoapods-fy-bin/helpers/upload_helper.rb
|
137
151
|
- lib/cocoapods-fy-bin/native.rb
|
152
|
+
- lib/cocoapods-fy-bin/native/201.rb
|
153
|
+
- lib/cocoapods-fy-bin/native/225.rb
|
138
154
|
- lib/cocoapods-fy-bin/native/acknowledgements.rb
|
139
155
|
- lib/cocoapods-fy-bin/native/analyzer.rb
|
140
156
|
- lib/cocoapods-fy-bin/native/file_accessor.rb
|
@@ -142,7 +158,7 @@ files:
|
|
142
158
|
- lib/cocoapods-fy-bin/native/installer.rb
|
143
159
|
- lib/cocoapods-fy-bin/native/linter.rb
|
144
160
|
- lib/cocoapods-fy-bin/native/path_source.rb
|
145
|
-
- lib/cocoapods-fy-bin/native/
|
161
|
+
- lib/cocoapods-fy-bin/native/pod_source_downloader.rb
|
146
162
|
- lib/cocoapods-fy-bin/native/pod_target_installer.rb
|
147
163
|
- lib/cocoapods-fy-bin/native/podfile.rb
|
148
164
|
- lib/cocoapods-fy-bin/native/podfile_env.rb
|
@@ -178,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
194
|
- !ruby/object:Gem::Version
|
179
195
|
version: '0'
|
180
196
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
197
|
+
rubygems_version: 3.1.4
|
182
198
|
signing_key:
|
183
199
|
specification_version: 4
|
184
200
|
summary: cocoapods-fy-bin is a plugin which helps develpers switching pods between
|