Skip to content

Instantly share code, notes, and snippets.

@PhilCai1993
Created December 12, 2019 12:56
Show Gist options
  • Select an option

  • Save PhilCai1993/a3f0fd8010fb0b294d95351bbc24c233 to your computer and use it in GitHub Desktop.

Select an option

Save PhilCai1993/a3f0fd8010fb0b294d95351bbc24c233 to your computer and use it in GitHub Desktop.
Save disk space for victims of CocoaPods
gem 'cocoapods', '1.7.4'# only 1.7.4 tested.
require 'cocoapods'
module Pod
class Installer
def clean_pod_sources
UI.message "prevent default clean_pod_sources"
end
end
end
module Pod
module Downloader
def self.download(
request,
target,
can_cache: true,
cache_path: Config.instance.cache_root + 'Pods'
)
can_cache &&= !Config.instance.skip_download_cache
request = preprocess_request(request)
if can_cache
raise ArgumentError, 'Must provide a `cache_path` when caching.' unless cache_path
cache = Cache.new(cache_path)
result = cache.download_pod(request)
else
raise ArgumentError, 'Must provide a `target` when caching is disabled.' unless target
require 'cocoapods/installer/pod_source_preparer'
result, = download_request(request, target)
Installer::PodSourcePreparer.new(result.spec, result.location).prepare!
end
if target && result.location && target != result.location
UI.message "Symlinking #{request.name} from `#{result.location}` to #{UI.path target}", '> ' do
FileUtils.rm_rf target
FileUtils.symlink(result.location, target)
end
end
result
end
end
end
module Pod
class Sandbox
class PathList
def read_file_system
unless root.exist?
raise Informative, "Attempt to read non existent folder `#{root}`."
end
dirs = []
files = []
root_length = root.cleanpath.to_s.length + File::SEPARATOR.length
Dir.glob(root.to_s + '/**/**/**') do |f|
directory = File.directory?(f)
f = f.slice(root_length, f.length - root_length)
next if f.nil?
(directory ? dirs : files) << f
end
dirs.sort_by!(&:upcase)
files.sort_by!(&:upcase)
@dirs = dirs
@files = files
@glob_cache = {}
end
end
end
end
@PhilCai1993

Copy link
Copy Markdown
Author

Just import this file in the Podfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment