Skip to content

Commit 6307bf8

Browse files
committed
add keep_source_code_for_prebuilt_frameworks!
1 parent fa30f90 commit 6307bf8

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

lib/cocoapods-binary/Main.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ def enable_bitcode_for_prebuilt_frameworks!
1717
DSL.bitcode_enabled = true
1818
end
1919

20+
# Don't remove source code of prebuilt pods
21+
# It may speed up the pod install if git didn't
22+
# include the `Pods` folder
23+
def keep_source_code_for_prebuilt_frameworks!
24+
DSL.dont_remove_source_code = true
25+
end
26+
2027
private
2128
class_attr_accessor :prebuild_all
2229
prebuild_all = false
2330

2431
class_attr_accessor :bitcode_enabled
2532
bitcode_enabled = false
33+
34+
class_attr_accessor :dont_remove_source_code
35+
dont_remove_source_code = false
2636
end
2737
end
2838
end

lib/cocoapods-binary/Prebuild.rb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,6 @@ def prebuild_frameworks!
166166
end
167167

168168
# Remove useless files
169-
# only keep manifest.lock and framework folder in _Prebuild
170-
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
171-
to_delete_files = sandbox_path.children.select do |file|
172-
filename = File.basename(file)
173-
not to_remain_files.include?(filename)
174-
end
175-
to_delete_files.each do |path|
176-
path.rmtree if path.exist?
177-
end
178169
# remove useless pods
179170
all_needed_names = self.pod_targets.map(&:name).uniq
180171
useless_names = sandbox.exsited_framework_names.reject do |name|
@@ -185,6 +176,24 @@ def prebuild_frameworks!
185176
path.rmtree if path.exist?
186177
end
187178

179+
if not Podfile::DSL.dont_remove_source_code
180+
# only keep manifest.lock and framework folder in _Prebuild
181+
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
182+
to_delete_files = sandbox_path.children.select do |file|
183+
filename = File.basename(file)
184+
not to_remain_files.include?(filename)
185+
end
186+
to_delete_files.each do |path|
187+
path.rmtree if path.exist?
188+
end
189+
else
190+
# just remove the tmp files
191+
path = sandbox.root + 'Manifest.lock.tmp'
192+
path.rmtree if path.exist?
193+
end
194+
195+
196+
188197
end
189198

190199

0 commit comments

Comments
 (0)