這是在mac上,開發flutter項目時,引入某些第三方包時出現的報錯原因時需要安裝cocoapods,所以出此教程
整整配置了兩天,各種坑,欲哭無淚!!!!!!!!
1.首先,安裝Homebrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝成功後截圖(時間還是比較長的)
2.接下來是安裝rvm。先查看下curl版本
$ curl --version
然後執行下面命令進行安裝rvm
$ curl -L get.rvm.io | bash -s stable
指定源
$ source ~/.rvm/scripts/rvm
完成後查看安裝是否成功,如下圖
$ rvm -v
執行
rvm list known
選擇一個版本進行安裝
$ rvm install 2.6
3.最後安裝cocoapods
檢查ruby源並移除
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
出現報錯,無法要求openssl,安裝openssl並重新構建Ruby(首選)或使用非https源
rvm get stable
brew update
brew doctor
brew install openssl
rvm use ruby-2.6.0
rvm gemset create jekyll
gem install jekyll
各種問題心態都快繃不住了,才知道,是由於淘寶的tuby源不能用了
我們先刪除原來的ruby源然後更新爲
gem sources -a https://gems.ruby-china.com/
gem sources -a https://gems.ruby-china.com/
安裝CocoaPods,這裏要注意:
- OS X 10.11之前系統的安裝cocoapods 指令:
$ sudo gem install cocoapods
- OS X 10.11以後系統的安裝cocoapods 指令:
$ sudo gem install -n /usr/local/bin cocoa pods
最後執行
sudo gem install cocoapods
進入到你的項目工程文件下夾下
pod init
如果已有podfile文件
pod install
此時發現速度是非常慢的,在生成/.cocoapods/repos/目錄後停止掉clone,手動下載包。
1、首先去github上下載.zip文件:https://github.com/CocoaPods/Specs
2、將下載的 master.zip 解壓出來,解壓後的文件目錄:
3、將解壓出來的文件目錄複製到 /.cocoapods/repos/master 目錄:
4、 然後cd到master目錄:
cd ~/.cocoapods/repos/master
5、初始化git:
git init
6、關聯倉庫:
git remote add origin https://github.com/CocoaPods/Specs
7、查看我們的repo是否正常,終端輸入:
pod repo
8、 最後測試下 pod search 和
pod install
,都可以正常使用了。