2019安装cocoaPods

检索关键词:2019 CocoaPods使用

 

查看版本:gem --version

输出: 2.7.7

 

更换Ruby 源:

gem sources --remove https://rubygems.org/

gem sources --add https://gems.ruby-china.com/

淘宝的源好像不能用了用这个:https://gems.ruby-china.com/

 

安装cocoapods:   sudo gem install cocoapods

报错:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

输入:   sudo gem install -n /usr/local/bin cocoapods

输出:

复制代码
Successfully installed httpclient-2.8.3
Fetching: algoliasearch-1.27.1.gem (100%)
Successfully installed algoliasearch-1.27.1
Fetching: cocoapods-core-1.8.4.gem (100%)
Successfully installed cocoapods-core-1.8.4
Fetching: cocoapods-deintegrate-1.0.4.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.4
Fetching: cocoapods-downloader-1.3.0.gem (100%)
Successfully installed cocoapods-downloader-1.3.0
Fetching: cocoapods-trunk-1.4.1.gem (100%)
Successfully installed cocoapods-trunk-1.4.1
Fetching: molinillo-0.6.6.gem (100%)
Successfully installed molinillo-0.6.6
Fetching: atomos-0.1.3.gem (100%)
Successfully installed atomos-0.1.3
Fetching: xcodeproj-1.13.0.gem (100%)
Successfully installed xcodeproj-1.13.0
Fetching: fourflusher-2.3.1.gem (100%)
Successfully installed fourflusher-2.3.1
Fetching: ruby-macho-1.4.0.gem (100%)
Successfully installed ruby-macho-1.4.0
Fetching: cocoapods-1.8.4.gem (100%)
Successfully installed cocoapods-1.8.4
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.1
Installing ri documentation for algoliasearch-1.27.1
Parsing documentation for cocoapods-core-1.8.4
Installing ri documentation for cocoapods-core-1.8.4
Parsing documentation for cocoapods-deintegrate-1.0.4
Installing ri documentation for cocoapods-deintegrate-1.0.4
Parsing documentation for cocoapods-downloader-1.3.0
Installing ri documentation for cocoapods-downloader-1.3.0
Parsing documentation for cocoapods-trunk-1.4.1
Installing ri documentation for cocoapods-trunk-1.4.1
Parsing documentation for molinillo-0.6.6
Installing ri documentation for molinillo-0.6.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for xcodeproj-1.13.0
Installing ri documentation for xcodeproj-1.13.0
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.8.4
Installing ri documentation for cocoapods-1.8.4
Done installing documentation for httpclient, algoliasearch, cocoapods-core, cocoapods-deintegrate, cocoapods-downloader, cocoapods-trunk, molinillo, atomos, xcodeproj, fourflusher, ruby-macho, cocoapods after 13 seconds
12 gems installed
复制代码

 

查看pod版本:pod --version

输出:1.8.4

 

cd到项目目录,

创建podfile:   touch Podfile,

在podfile填入内容:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

target 'test' do
 pod 'SDWebImage'
end

 

安装SDWebImage: pod install,注意,podfile里面的注释不是//,双斜线pod install会报错

 

pod install 报错:

CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/1/1/7/SDWebImage/5.4.0/SDWebImage.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443)

在podfile最上面添加  source 'https://github.com/CocoaPods/Specs.git':

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

target 'test' do
 pod 'SDWebImage'

end

 

再次 pod install, 报错:

复制代码
[!] CocoaPods could not find compatible versions for pod "SDWebImage":
  In Podfile:
    SDWebImage (~> 5.0)

None of your spec sources contain a spec satisfying the dependency: `SDWebImage (~> 5.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.
复制代码

修改pod file,去掉sdwebimage指定的版本号:

 pod 'SDWebImage'

然后pod install

安装成功,重启xcode,运行OK

 

posted on   土匪7  阅读(671)  评论(0编辑  收藏  举报

编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示