記:CocoaPods 安裝FMDB第一次嘗試

錯誤

  • 錯誤類型 1:
[!] Invalid `Podfile` file: syntax error, unexpected ',', expecting end-of-input
'FMDB','~>2.6.2'
[!] Invalid `Podfile` file: syntax error, unexpected tSTRING_BEG, expecting end-of-input
platform:ios'8.0'
[!] The dependency `FMDB (~> 2.6.2)` is not used in any concrete target.
[!] Invalid `Podfile` file: syntax error, unexpected end-of-input, expecting keyword_end.

錯誤原因:podfile的配置不對,正確的配置如下:
platform :ios, '8.0'
target "no_name" do
pod 'FMDB', '~> 2.6.2'
end
注:標點和空格 一定要正確

  • 錯誤類型 2:
 [!] Unable to satisfy the following requirements:
`FMDB (~> 2.6.2)` required by `Podfile`
None of your spec sources contain a spec satisfying the dependency: `FMDB (~> 2.6.2)`.
You have either:
 * out-of-date source repos which you can update with `pod repo update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.
執行下面命令
sudo gem install cocoapods --pre
報錯
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod
執行下面命令
// 移除本地master
sudo rm -fr ~/.cocoapods/repos/master
// 移除本地緩存
sudo rm -fr ~/Library/Caches/CocoaPods/
// 重新setup,如果網速較慢,可以在后面加上 --verbose
pod setup
報錯
Setting up CocoaPods master repo
[!] The `master` repo requires CocoaPods 1.0.0 -  (currently using 0.36.4)
Update CocoaPods, or checkout the appropriate tag in the repo.
localhost:no_name Loji$ sudo gem update cocoapods
Password:
Updating installed gems
Updating cocoapods
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod
執行命令
sudo gem install -n /usr/local/bin cocoapods
成功Successfully installed cocoapods-1.1.1
重新執行:pod setup
出現藍色字體Setup completed
pod install  成功
```
####CocoaPods常用命令
1. pod install
根據Podfile文件指定的內容,安裝依賴庫,如果有Podfile.lock文件而且對應的Podfile文件未被修改,則會根據Podfile.lock文件指定的版本安裝。
每次更新了Podfile文件時,都需要重新執行該命令,以便重新安裝Pods依賴庫。
2. pod update
若果Podfile中指定的依賴庫版本不是寫死的,當對應的依賴庫有了更新,無論有沒有Podfile.lock文件都會去獲取Podfile文件描述的允許獲取到的最新依賴庫版本。
3. pod search <第三方庫>
4. pod --version 查看版本
5. sudo gem uninstall cocoapods 卸載cocoapods
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容