Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ end

If you want to disable binary for a specific pod when using `all_binary!`, place a `:binary => false` to it.

If your `Pods` folder is excluded from git, you may add `keep_source_code_for_prebuilt_frameworks!` in the head of Podfile to speed up pod install, as it won't download all the sources every time prebuilt pods have changes.

If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all targets in Podfile


#### Known Issues

- doesn't support watchos now
Expand Down
10 changes: 10 additions & 0 deletions lib/cocoapods-binary/Main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ def enable_bitcode_for_prebuilt_frameworks!
DSL.bitcode_enabled = true
end

# Don't remove source code of prebuilt pods
# It may speed up the pod install if git didn't
# include the `Pods` folder
def keep_source_code_for_prebuilt_frameworks!
DSL.dont_remove_source_code = true
end

private
class_attr_accessor :prebuild_all
prebuild_all = false

class_attr_accessor :bitcode_enabled
bitcode_enabled = false

class_attr_accessor :dont_remove_source_code
dont_remove_source_code = false
end
end
end
Expand Down
27 changes: 18 additions & 9 deletions lib/cocoapods-binary/Prebuild.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,6 @@ def prebuild_frameworks!
end

# Remove useless files
# only keep manifest.lock and framework folder in _Prebuild
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
to_delete_files = sandbox_path.children.select do |file|
filename = File.basename(file)
not to_remain_files.include?(filename)
end
to_delete_files.each do |path|
path.rmtree if path.exist?
end
# remove useless pods
all_needed_names = self.pod_targets.map(&:name).uniq
useless_names = sandbox.exsited_framework_names.reject do |name|
Expand All @@ -185,6 +176,24 @@ def prebuild_frameworks!
path.rmtree if path.exist?
end

if not Podfile::DSL.dont_remove_source_code
# only keep manifest.lock and framework folder in _Prebuild
to_remain_files = ["Manifest.lock", File.basename(existed_framework_folder)]
to_delete_files = sandbox_path.children.select do |file|
filename = File.basename(file)
not to_remain_files.include?(filename)
end
to_delete_files.each do |path|
path.rmtree if path.exist?
end
else
# just remove the tmp files
path = sandbox.root + 'Manifest.lock.tmp'
path.rmtree if path.exist?
end



end


Expand Down
8 changes: 7 additions & 1 deletion test/change_podfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def save_to_podfile(text):
def initial():
return (wrapper(
"""
keep_source_code_for_prebuilt_frameworks!

pod "Masonry"
"""),
"""
Expand All @@ -39,6 +41,8 @@ def initial():
def addSwiftPod():
return (wrapper(
"""
keep_source_code_for_prebuilt_frameworks!

pod "RxCocoa", :binary => true
pod "Literal", :binary => true
"""),
Expand All @@ -50,6 +54,8 @@ def addSwiftPod():
def revertToSourceCode():
return (wrapper(
"""
keep_source_code_for_prebuilt_frameworks!

pod "RxCocoa", :binary => true
pod "Literal"
"""),
Expand Down Expand Up @@ -132,5 +138,5 @@ def universalFlag():

if __name__ == "__main__":
arg = sys.argv[1]
print("change Podfile to: " + arg)
print("===================\nchange Podfile to: " + arg + "\n")
save_to_podfile(globals()[arg]())