Cocoapad安装和依赖添加

首先要看下你 mac 电脑安装的 ruby 版本是多少:
ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]

我的 mac 电脑ruby 版本已经很高了,不用升级。

由于国内被墙的原因,需要更换 gem 镜像源:
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
source https://gems.ruby-china.com/ already present in the cache
这样就将镜像源给更换过来了。

此时可以安装Cocoapad的了:

gem install cocoapods
Fetching nanaimo-0.3.0.gem
Fetching colored2-3.1.2.gem
Fetching claide-1.1.0.gem
Fetching CFPropertyList-3.0.6.gem
Fetching atomos-0.1.3.gem
Fetching xcodeproj-1.23.0.gem
Fetching ruby-macho-2.5.1.gem
Fetching nap-1.1.0.gem
Fetching molinillo-0.8.0.gem
Fetching gh_inspector-1.1.3.gem
Fetching fourflusher-2.3.1.gem
Fetching escape-0.0.4.gem
Fetching cocoapods-try-1.2.0.gem
Fetching netrc-0.11.0.gem
Fetching cocoapods-trunk-1.6.0.gem
Fetching cocoapods-search-1.0.1.gem
Fetching cocoapods-plugins-1.0.0.gem
Fetching cocoapods-downloader-2.1.gem
Fetching cocoapods-deintegrate-1.0.5.gem
Fetching ffi-1.16.3.gem
Fetching ethon-0.16.0.gem
Fetching typhoeus-1.4.1.gem
Fetching public_suffix-4.0.7.gem
Fetching fuzzy_match-2.0.4.gem
Fetching concurrent-ruby-1.2.2.gem
Fetching httpclient-2.8.3.gem
Fetching algoliasearch-1.27.5.gem
Fetching addressable-2.8.6.gem
Fetching tzinfo-2.0.6.gem
Fetching i18n-1.14.1.gem
Fetching connection_pool-2.4.1.gem
Fetching activesupport-7.1.2.gem
Fetching cocoapods-1.14.3.gem
Fetching cocoapods-core-1.14.3.gem
Successfully installed nanaimo-0.3.0
Successfully installed colored2-3.1.2
Successfully installed claide-1.1.0
Successfully installed CFPropertyList-3.0.6
Successfully installed atomos-0.1.3
Successfully installed xcodeproj-1.23.0
Successfully installed ruby-macho-2.5.1
Successfully installed nap-1.1.0
Successfully installed molinillo-0.8.0
Successfully installed gh_inspector-1.1.3
Successfully installed fourflusher-2.3.1
Successfully installed escape-0.0.4
Successfully installed cocoapods-try-1.2.0
Successfully installed netrc-0.11.0
Successfully installed cocoapods-trunk-1.6.0
Successfully installed cocoapods-search-1.0.1
Successfully installed cocoapods-plugins-1.0.0
Successfully installed cocoapods-downloader-2.1
Successfully installed cocoapods-deintegrate-1.0.5
Building native extensions. This could take a while…
Successfully installed ffi-1.16.3
Successfully installed ethon-0.16.0
Successfully installed typhoeus-1.4.1
Successfully installed public_suffix-4.0.7
Successfully installed fuzzy_match-2.0.4
Successfully installed concurrent-ruby-1.2.2
Successfully installed httpclient-2.8.3
A new major version is available for Algolia! Please now use the https://rubygems.org/gems/algolia gem to get the latest features.
Successfully installed algoliasearch-1.27.5
Successfully installed addressable-2.8.6
Successfully installed tzinfo-2.0.6
Successfully installed i18n-1.14.1
Successfully installed connection_pool-2.4.1
Successfully installed activesupport-7.1.2
Successfully installed cocoapods-core-1.14.3
Successfully installed cocoapods-1.14.3
Parsing documentation for nanaimo-0.3.0
Installing ri documentation for nanaimo-0.3.0
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for claide-1.1.0
Installing ri documentation for claide-1.1.0
Parsing documentation for CFPropertyList-3.0.6
Installing ri documentation for CFPropertyList-3.0.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for xcodeproj-1.23.0
Installing ri documentation for xcodeproj-1.23.0
Parsing documentation for ruby-macho-2.5.1
Installing ri documentation for ruby-macho-2.5.1
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for molinillo-0.8.0
Installing ri documentation for molinillo-0.8.0
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for cocoapods-try-1.2.0
Installing ri documentation for cocoapods-try-1.2.0
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for cocoapods-trunk-1.6.0
Installing ri documentation for cocoapods-trunk-1.6.0
Parsing documentation for cocoapods-search-1.0.1
Installing ri documentation for cocoapods-search-1.0.1
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-downloader-2.1
Installing ri documentation for cocoapods-downloader-2.1
Parsing documentation for cocoapods-deintegrate-1.0.5
Installing ri documentation for cocoapods-deintegrate-1.0.5
Parsing documentation for ffi-1.16.3
Installing ri documentation for ffi-1.16.3
Parsing documentation for ethon-0.16.0
Installing ri documentation for ethon-0.16.0
Parsing documentation for typhoeus-1.4.1
Installing ri documentation for typhoeus-1.4.1
Parsing documentation for public_suffix-4.0.7
Installing ri documentation for public_suffix-4.0.7
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for concurrent-ruby-1.2.2
Installing ri documentation for concurrent-ruby-1.2.2
Parsing documentation for httpclient-2.8.3
Installing ri documentation for httpclient-2.8.3
Parsing documentation for algoliasearch-1.27.5
Installing ri documentation for algoliasearch-1.27.5
Parsing documentation for addressable-2.8.6
Installing ri documentation for addressable-2.8.6
Parsing documentation for tzinfo-2.0.6
Installing ri documentation for tzinfo-2.0.6
Parsing documentation for i18n-1.14.1
Installing ri documentation for i18n-1.14.1
Parsing documentation for connection_pool-2.4.1
Installing ri documentation for connection_pool-2.4.1
Parsing documentation for activesupport-7.1.2
Couldn’t find file to include ‘activesupport/README.rdoc’ from lib/active_support.rb
Installing ri documentation for activesupport-7.1.2
Parsing documentation for cocoapods-core-1.14.3
Installing ri documentation for cocoapods-core-1.14.3
Parsing documentation for cocoapods-1.14.3
Installing ri documentation for cocoapods-1.14.3
Done installing documentation for nanaimo, colored2, claide, CFPropertyList, atomos, xcodeproj, ruby-macho, nap, molinillo, gh_inspector, fourflusher, escape, cocoapods-try, netrc, cocoapods-trunk, cocoapods-search, cocoapods-plugins, cocoapods-downloader, cocoapods-deintegrate, ffi, ethon, typhoeus, public_suffix, fuzzy_match, concurrent-ruby, httpclient, algoliasearch, addressable, tzinfo, i18n, connection_pool, activesupport, cocoapods-core, cocoapods after 25 seconds
34 gems installed

A new release of RubyGems is available: 3.5.3 → 3.5.4!
Run gem update --system 3.5.4 to update your installation.

有更新的 rubyGem 版本3.5.4 。 直接升级

gem update --system 3.5.4
Updating rubygems-update
Fetching rubygems-update-3.5.4.gem
Successfully installed rubygems-update-3.5.4
Parsing documentation for rubygems-update-3.5.4
Installing ri documentation for rubygems-update-3.5.4
Done installing documentation for rubygems-update after 1 seconds
Parsing documentation for rubygems-update-3.5.4
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.5.4
Successfully built RubyGem
Name: bundler
Version: 2.5.4
File: bundler-2.5.4.gem
Bundler 2.5.4 installed
RubyGems 3.5.4 installed
Regenerating binstubs
Regenerating plugins
Parsing documentation for rubygems-3.5.4
Installing ri documentation for rubygems-3.5.4

3.5.4 / 2024-01-03

Enhancements:

  • Always avoid “Updating rubygems-update” message. Pull request
    #7335 by
    deivid-rodriguez
  • Installs bundler 2.5.4 as a default gem.

Bug fixes:

  • Make gem update --system respect ruby version constraints. Pull
    request #7334 by
    deivid-rodriguez

RubyGems installed the following executables:
/Users/xin.yu/.rbenv/versions/3.3.0/bin/gem
/Users/xin.yu/.rbenv/versions/3.3.0/bin/bundle
/Users/xin.yu/.rbenv/versions/3.3.0/bin/bundler

Ruby Interactive (ri) documentation was installed. ri is kind of like man
pages for Ruby libraries. You may access it like this:
ri Classname
ri Classname.class_method
ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
–no-document flag, or set it as the default in your ~/.gemrc file. See
‘gem help env’ for details.

RubyGems system software updated
192:~ xin.yu$ pod repo remove master
[!] repo master does not exist
Usage:
$ pod repo remove NAME
Deletes the remote named NAME from the local spec-repos directory at
/Users/xin.yu/.cocoapods/repos.
Options:
–allow-root Allows CocoaPods to run as root
–silent Show nothing
–verbose Show more debugging information
–no-ansi Show output without ANSI codes
–help Show help banner of specified command
192:~ xin.yu$ pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
Cloning spec repo master from https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

ls
MyFirstIosDemo Podfile
MyFirstIosDemo.xcodeproj
192:MyFirstIosDemo xin.yu$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use MyFirstIosDemo.xcworkspace for this project from now on.
Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed.

[!] The Podfile does not contain any dependencies.

[!] Automatically assigning platform iOS with version 16.4 on target MyFirstIosDemo because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.
192:MyFirstIosDemo xin.yu$ pod install
Analyzing dependencies
Adding spec repo trunk with CDN https://cdn.cocoapods.org/
Downloading dependencies
Installing Masonry (1.1.0)

[!] Error installing Masonry
[!] /usr/bin/git clone https://github.com/cloudkite/Masonry.git /var/folders/np/qkjb8ztj3_76bmfv6t58gx5c0000gn/T/d20240108-68959-2sw5gv --template= --single-branch --depth 1 --branch v1.1.0

Cloning into ‘/var/folders/np/qkjb8ztj3_76bmfv6t58gx5c0000gn/T/d20240108-68959-2sw5gv’…
fatal: unable to access ‘https://github.com/cloudkite/Masonry.git/’: HTTP/2 stream 1 was not closed cleanly before end of the underlying stream

[!] Automatically assigning platform iOS with version 16.4 on target MyFirstIosDemo because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.
192:MyFirstIosDemo xin.yu$
192:MyFirstIosDemo xin.yu$ pod install
Analyzing dependencies
Downloading dependencies
Installing Masonry (1.1.0)

[!] Error installing Masonry
[!] /usr/bin/git clone https://github.com/cloudkite/Masonry.git /var/folders/np/qkjb8ztj3_76bmfv6t58gx5c0000gn/T/d20240108-68993-fmewmw --template= --single-branch --depth 1 --branch v1.1.0

Cloning into ‘/var/folders/np/qkjb8ztj3_76bmfv6t58gx5c0000gn/T/d20240108-68993-fmewmw’…
fatal: unable to access ‘https://github.com/cloudkite/Masonry.git/’: Failed to connect to github.com port 443 after 75030 ms: Couldn’t connect to server

[!] Automatically assigning platform iOS with version 16.4 on target MyFirstIosDemo because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.
192:MyFirstIosDemo xin.yu$ pod repo remove master
Removing spec repo master
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

192:MyFirstIosDemo :$ pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
Cloning spec repo master from https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git

pod install
Analyzing dependencies
Downloading dependencies
Installing Masonry (1.1.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] Automatically assigning platform iOS with version 16.4 on target MyFirstIosDemo because no platform was specified. Please specify a platform for this target in your Podfile. See https://guides.cocoapods.org/syntax/podfile.html#platform.

又是因为镜像源不行,导致依赖下载不下来,更换镜像源后,Masonry成功下载,并添加。

你可能感兴趣的:(iOS,开发,ios,cocoapods)