Class: Pod::Installer
- Inherits:
-
Object
show all
- Defined in:
- lib/cocoapods-fy-bin/native/analyzer.rb,
lib/cocoapods-fy-bin/native/installer.rb,
lib/cocoapods-fy-bin/native/sandbox_analyzer.rb,
lib/cocoapods-fy-bin/native/target_validator.rb,
lib/cocoapods-fy-bin/native/installation_options.rb,
lib/cocoapods-fy-bin/native/pod_target_installer.rb,
lib/cocoapods-fy-bin/native/pod_source_downloader.rb
Defined Under Namespace
Classes: Analyzer, InstallationOptions, PodSourceDownloader, Xcode
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#removed_frameworks ⇒ Object
Returns the value of attribute removed_frameworks.
10
11
12
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 10
def removed_frameworks
@removed_frameworks
end
|
Instance Method Details
#cache_descriptors ⇒ Object
18
19
20
21
22
23
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 18
def cache_descriptors
@cache_descriptors ||= begin
cache = Downloader::Cache.new(Config.instance.cache_root + 'Pods')
cache_descriptors = cache.cache_descriptors_per_pod
end
end
|
#clean_local_cache ⇒ Object
清除项目中不使用二进制的二进制库 工程目录/Pods/组件名称
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 25
def clean_local_cache
podfile = Pod::Config.instance.podfile
title_options = { verbose_prefix: '-> '.red }
root_specs.sort_by(&:name).each do |spec|
pod_dir = Pod::Config.instance.sandbox.pod_dir(spec.root.name)
framework_file = pod_dir + "#{spec.root.name}.framework"
if pod_dir.exist? && framework_file.exist? && (podfile.use_binaries_selector.nil? || !podfile.use_binaries_selector.call(spec)) && !clean_white_list.include?(spec.root.name)
title = "Remove Binary Framework #{spec.name} #{spec.version}"
UI.titled_section(title.red, title_options) do
@removed_frameworks << spec.root.name
begin
FileUtils.rm_rf(pod_dir)
rescue => err
puts err
end
end
end
end
end
|
#clean_pod_cache ⇒ Object
清除本地资源 /Users/dengrui/Library/Caches/CocoaPods/Pods/Release/
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 47
def clean_pod_cache
podfile = Pod::Config.instance.podfile
root_specs.sort_by(&:name).each do |spec|
descriptors = cache_descriptors[spec.root.name]
if !descriptors.nil?
descriptors = descriptors.select { |d| d[:version] == spec.version}
descriptors.each do |d|
slug = d[:slug].dirname + "#{spec.version}-#{spec.checksum[0, 5]}"
puts slug
framework_file = slug + "#{spec.root.name}.framework"
puts framework_file
if framework_file.exist? && (podfile.use_binaries_selector.nil? || !podfile.use_binaries_selector.call(spec)) && !clean_white_list.include?(spec.root.name)
begin
FileUtils.rm(d[:spec_file])
FileUtils.rm_rf(slug)
rescue => err
puts err
end
end
end
end
end
end
|
#clean_white_list ⇒ Object
12
13
14
15
16
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 12
def clean_white_list
clean_white_string = CBin.config.clean_white_list
clean_white = clean_white_string.split(",")
clean_white
end
|
#create_pod_installer(pod_name) ⇒ Object
75
76
77
78
79
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 75
def create_pod_installer(pod_name)
installer = old_create_pod_installer(pod_name)
installer
end
|
#install_pod_sources ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 82
def install_pod_sources
@clean_white_list = ['Bugly', 'LookinServer']
@removed_frameworks = Array.new
podfile = Pod::Config.instance.podfile
if !podfile.use_binaries?
clean_local_cache
clean_pod_cache
end
if installation_options.install_with_multi_threads
if Pod.match_version?('~> 1.4.0')
install_pod_sources_for_version_in_1_4_0
elsif Pod.match_version?('~> 1.5')
install_pod_sources_for_version_above_1_5_0
else
old_install_pod_sources
end
else
old_install_pod_sources
end
end
|
#install_pod_sources_for_version_above_1_5_0 ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 129
def install_pod_sources_for_version_above_1_5_0
@installed_specs = []
pods_to_install = sandbox_state.added | sandbox_state.changed | removed_frameworks
title_options = { verbose_prefix: '-> '.green }
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
if pods_to_install.include?(spec.name)
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
current_version = spec.version
previous_version = sandbox.manifest.version(spec.name)
has_changed_version = current_version != previous_version
current_repo = analysis_result.specs_by_source.detect do |key, values|
break key if values.map(&:name).include?(spec.name)
end
current_repo &&= current_repo.url || current_repo.name
previous_spec_repo = sandbox.manifest.spec_repo(spec.name)
has_changed_repo = !previous_spec_repo.nil? && current_repo && (current_repo != previous_spec_repo)
title = "Installing #{spec.name} #{spec.version}"
if has_changed_version && has_changed_repo
title += " (was #{previous_version} and source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
end
if has_changed_version && !has_changed_repo
title += " (was #{previous_version})"
end
if !has_changed_version && has_changed_repo
title += " (source changed to `#{current_repo}` from `#{previous_spec_repo}`)"
end
else
title = "Installing #{spec}"
end
UI.titled_section(title.green, title_options) do
install_source_of_pod(spec.name)
end
else
UI.titled_section("Using #{spec}", title_options) do
create_pod_installer(spec.name)
end
end
end
end
|
#install_pod_sources_for_version_in_1_4_0 ⇒ Object
rewrite install_pod_sources
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 106
def install_pod_sources_for_version_in_1_4_0
@installed_specs = []
pods_to_install = sandbox_state.added | sandbox_state.changed
title_options = { verbose_prefix: '-> '.green }
Parallel.each(root_specs.sort_by(&:name), in_threads: 4) do |spec|
if pods_to_install.include?(spec.name)
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
previous = sandbox.manifest.version(spec.name)
title = "Installing #{spec.name} #{spec.version} (was #{previous})"
else
title = "Installing #{spec}"
end
UI.titled_section(title.green, title_options) do
install_source_of_pod(spec.name)
end
else
UI.titled_section("Using #{spec}", title_options) do
create_pod_installer(spec.name)
end
end
end
end
|
#old_create_pod_installer ⇒ Object
74
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 74
alias old_create_pod_installer create_pod_installer
|
#old_install_pod_sources ⇒ Object
81
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 81
alias old_install_pod_sources install_pod_sources
|
#old_write_lockfiles ⇒ Object
171
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 171
alias old_write_lockfiles write_lockfiles
|
#write_lockfiles ⇒ Object
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/cocoapods-fy-bin/native/installer.rb', line 172
def write_lockfiles
old_write_lockfiles
if File.exist?('Podfile_local')
project = Xcodeproj::Project.open(config.sandbox.project_path)
group = project.main_group
group.set_source_tree('SOURCE_ROOT')
file_ref = group.new_reference(config.sandbox.root + '../Podfile_local')
podfile_local_group = group.children.last
group.children.pop
group.children.unshift(podfile_local_group)
project.save
end
end
|