常見命令
安裝
sudo gem install cocoapods
通過gem來安裝cocoapods(上面命令會(huì)訪問https://rubygems.org/)然后就被墻了
gem sources -l
通過該命令來查看當(dāng)前的源
1.gem sources --remove https://rubygems.org/
2.gem sources -a http://ruby.taobao.org/
上面2個(gè)命令然后鏡像到國內(nèi)的 都說淘寶的不能用了 如果不行的話試試下面這個(gè)
gem source -r https://ruby.taobao.org
gem source -a https://gems.ruby-china.org
gem source -u # 更新 update
換完了源之后再重新執(zhí)行 sudo gem install cocoapods
pod setup 用來同步master上的庫敌买。我們需要經(jīng)常執(zhí)行這條命令袁勺,否則有新的Pods依賴庫的時(shí)候執(zhí)行pod search命令是搜不出來的
查看當(dāng)前安裝了哪些版本
gem list --local | grep cocoapods
結(jié)果如下
cocoapods (1.7.5, 1.7.3, 1.5.3, 1.5.2, 1.5.0)
cocoapods-core (1.7.5, 1.7.3, 1.5.3, 1.5.2, 1.5.0)
cocoapods-deintegrate (1.0.4, 1.0.2)
cocoapods-downloader (1.2.2, 1.2.0)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.1, 1.3.0)
cocoapods-try (1.1.0)
刪除安裝過的所有版本
sudo gem uninstall cocoapods
強(qiáng)制卸載某一個(gè)版本
gem uninstall cocoapods -v xxx
安裝指定版本
sudo gem install cocoapods -v xxx.xxx.xxx
幫助命令
可以通過 pod --help 查看相關(guān)命令
創(chuàng)建Podfile文件
cd到文件下 pod init
pod install 生成的Podfile.lock文件 lock文件會(huì)保存pod版本
pod update 重新生成Podfile.lock文件
pod install --verbose --no-repo-update 可快速更新忽略本地repo的更新
cocoapod常見報(bào)錯(cuò)
更新gem報(bào)錯(cuò)(sudo gem update --system)
錯(cuò)誤一:
ERROR: While executing gem … (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj
沒有權(quán)限操作/usr/bin
目錄擦秽,可以映射到/usr/local/bin
文件下
執(zhí)行sudo gem install -n /usr/local/bin cocoapods
錯(cuò)誤二:
While executing gem … (Errno::EPERM)
Operation not permitted - /usr/bin/update_rubygems
安裝Homebrew(Homebrew installs the stuff you need that Apple didn’t.)
objc /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
當(dāng)pod install失敗的時(shí)候可以嘗試先卸載再重新安裝試試