Fix the CocoaPods command pod install Installing packages on github.com is slow or failing

CocoaPods performing pod install installs packages on github.com, but github.com is very unstable. One solution is to use scripts to convert resources from github.com to resources from other domains.

CocoaPods v1.7.2

CocoaPods version 1.7.2 to start using https://cdn.cocoapods.org/ instead of the original from https://github.com/CocoaPods/Specs.git, so that we can according to need to download package definition, Instead of downloading the entire Specs library at once (the entire library is around 3GB), refer to CocoaPods 1.7.2 — Master Repo CDN is XIV XIV! .

source 'https://github.com/artsy/Specs.git'
- source 'https://github.com/CocoaPods/Specs.git'
+ source 'https://cdn.cocoapods.org/'

The solution

Scripts are written using the python, is very simple, on https://github.com/senntyou/CocoaPods-Specs-Modify, if you want to use, need to clone to the local first.

git clone https://github.com/senntyou/CocoaPods-Specs-Modify.git

cd CocoaPods-Specs-Modify

python modify.py

The modify. Py script, the default specsDir take ~ /. Cocoapods/repos/trunk/Specs/targetSite github.com.cnpmjs.org/, can according to need to change, and then run the script

# Specs directory specsDir = OS. Path. Expanduser (' - ') + '/. Cocoapods/repos/trunk/Specs/' # # githubSite making domain name =' github.com/ ' Replace the domain name targetSite = 'github.com.cnpmjs.org/'

The sample

For example, the original package definition was

{"name": "mjRefresh ", "version": "3.6.1", "summary": "An easy way to use pull-to-file ", "homepage": "https://github.com/CoderMJLee/MJRefresh", "license": "MIT", "authors": { "MJ Lee": "[email protected]"}, "platforms" : {" ios ":" 9.0 "}, "source" : {" git ": "Https://github.com/CoderMJLee/MJRefresh.git", "tag" : "3.6.1 track"}, "source_files" : "MJRefresh / / *. * * {h, m}", "resources" : "MJRefresh/MJRefresh.bundle", "requires_arc": true }

The changed package becomes

{"name": "mjRefresh ", "version": "3.6.1", "summary": "An easy way to use pull-to-file ", "homepage": "https://github.com.cnpmjs.org/CoderMJLee/MJRefresh", "license": "MIT", "authors": { "MJ Lee": "[email protected]"}, "platforms" : {" ios ":" 9.0 "}, "source" : {" git ": "Https://github.com.cnpmjs.org/CoderMJLee/MJRefresh.git", "tag" : "3.6.1 track"}, "source_files" : "MJRefresh/**/*.{h,m}", "resources": "MJRefresh/MJRefresh.bundle", "requires_arc": true }

Github.com into github.com.cnpmjs.org

subsequent

More blogs, see https://github.com/senntyou/blogs

Author: Shen Yuzhi (@senntyou)

Copyright Notice: Free Reprint – Non-Commercial – Non-Derivative – Keep Your Name (Creative Commons 3.0 License)