1

Solve the problem that the CocoaPods command pod install installs the package on github.com very slowly or fails

CocoaPods running pod install will install the package on github.com github.com is very unstable.
One solution is to use a script to github.com the resources of 060bf3fb37936e to resources of other domains.

CocoaPods v1.7.2

CocoaPods from version 1.7.2 to start using https://cdn.cocoapods.org/ instead of the original https://github.com/CocoaPods/Specs.git ,
In this way, you can download the required package definitions on demand, instead of downloading the entire Specs library at once (the entire library is about 3GB), refer to CocoaPods 1.7.2 — Master Repo CDN is Finalized! .

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

solution

The script is python . It is very simple. Put it in https://github.com/senntyou/CocoaPods-Specs-Modify . If you want to use it, you need to clone it locally.

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

cd CocoaPods-Specs-Modify

python modify.py

modify.py script, the default specsDir ~/.cocoapods/repos/trunk/Specs/ , and targetSite github.com.cnpmjs.org/ , which can be changed as needed, and then run the script

# Specs目录
specsDir = os.path.expanduser('~') + '/.cocoapods/repos/trunk/Specs/'

# github 域名
githubSite = 'github.com/'

# 替换域名
targetSite = 'github.com.cnpmjs.org/'

Example

For example, the original package definition is

{
  "name": "MJRefresh",
  "version": "3.6.1",
  "summary": "An easy way to use pull-to-refresh",
  "homepage": "https://github.com/CoderMJLee/MJRefresh",
  "license": "MIT",
  "authors": {
    "MJ Lee": "richermj123go@vip.qq.com"
  },
  "platforms": {
    "ios": "9.0"
  },
  "source": {
    "git": "https://github.com/CoderMJLee/MJRefresh.git",
    "tag": "3.6.1"
  },
  "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-refresh",
  "homepage": "https://github.com.cnpmjs.org/CoderMJLee/MJRefresh",
  "license": "MIT",
  "authors": {
    "MJ Lee": "richermj123go@vip.qq.com"
  },
  "platforms": {
    "ios": "9.0"
  },
  "source": {
    "git": "https://github.com.cnpmjs.org/CoderMJLee/MJRefresh.git",
    "tag": "3.6.1"
  },
  "source_files": "MJRefresh/**/*.{h,m}",
  "resources": "MJRefresh/MJRefresh.bundle",
  "requires_arc": true
}

github.com becomes github.com.cnpmjs.org

Follow-up

For more blogs, check https://github.com/senntyou/blogs

Author: Shen Yuzhi (@senntyou)

Copyright notice: Freely reprinted-non-commercial-non-derivative-keep the signature ( Creative Commons 3.0 License )


深雨
12.7k 声望6.5k 粉丝

达则兼济天下,穷则独善其身。