macos catalina更新_所请求的macOS版本不可用

macos catalina更新_所请求的macOS版本不可用Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如http://rubygems.org/)源来查找、安装、升级和卸载软件包。 Gem是管理Ruby库和程序的标准包,如果它的版本过低也可能导致安装失败,解决方案升级Gem。 所有的项目的Podspec文件都托管…

MAC升级到macOS Catania之后重新安装了一下cocoapods

1,没有安装Homebrew的需要安装

使用国内源命令:/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

macos catalina更新_所请求的macOS版本不可用

可以看到集成了多个国内源,比较好用。

查检安装结果:brew -v

  • 遇到问题

    Homebrew 3.5.4-95-gf041a59 fatal: unsafe repository (‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’ is owned by someone else) To add an exception for this directory, call:

    git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
    

    Homebrew/homebrew-core (no Git repository) fatal: unsafe repository (‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask’ is owned by someone else) To add an exception for this directory, call:

    git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
    

    Homebrew/homebrew-cask (no Git repository)

按照报错提示,运行

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

有问题请参考:

https://zhuanlan.zhihu.com/p/90508170

安装RVM 参考 

https://blog.csdn.net/Heterogene/article/details/12493632

2,Ruby的安装

cocoaPods需要Ruby版本大于2.2.2

$ rvm list known   //查看ruby版本,可以看到已经有2.7.0的预览版了
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.6]
[ruby-]2.5[.5]
[ruby-]2.6[.3]
[ruby-]2.7[.0-preview1]
ruby-head


我选择了Ruby的2.6版本

$ rvm install 2.6    //安装2.6版本 下边设置默认也是选2.6
Warning, new version of rvm available '1.29.10', you are using older version '1.29.9'.
You can disable this warning with:   echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with:     echo rvm_autoupdate_flag=2 >> ~/.rvmrc
You can update manually with:        rvm get VERSION                         (e.g. 'rvm get stable')

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/mqing/.rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
** Resuming transfer from byte position 3503025
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.4M  100 10.4M    0     0  27259      0  0:06:43  0:06:43 --:--:-- 18965
ruby-2.6.3 - #extracting ruby-2.6.3 to /Users/mqing/.rvm/src/ruby-2.6.3.....
ruby-2.6.3 - #configuring......................................................|
ruby-2.6.3 - #post-configuration.
ruby-2.6.3 - #compiling........................................................|
ruby-2.6.3 - #installing...........
ruby-2.6.3 - #making binaries executable..
ruby-2.6.3 - #downloading rubygems-3.0.8
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  867k  100  867k    0     0  19460      0  0:00:45  0:00:45 --:--:-- 15735
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.3 - #extracting rubygems-3.0.8.....
ruby-2.6.3 - #removing old rubygems........
ruby-2.6.3 - #installing rubygems-3.0.8.........................................
ruby-2.6.3 - #gemset created /Users/mqing/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/mqing/.rvm/gemsets/global.gems...........-
ruby-2.6.3 - #generating global wrappers.......
ruby-2.6.3 - #gemset created /Users/mqing/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile /Users/mqing/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.3 - #generating default wrappers.......
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri

查看了一下ruby版本

$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]

这里需要设置一个默认版本(一定要设置下)

$ rvm use 2.6 --default
Using /Users/mqing/.rvm/gems/ruby-2.6.3
备注:
rvm use 2.6.3--default  //因为我看到具体版本号是2.6.3,第一次我执行了选择2.6.3,但是报错如下
Required ruby-2.6.3-default is not installed.



3,更换Gem源

Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如rubygems.org/)源来查找、安装、升级和卸载软件包。

// 1.移除掉原有的源(服务器在国外,速度较慢)
- gem sources --remove https://rubygems.org/
taobao Gems 已停止维护,现在有ruby-china提供镜像服务,如果安装了则删除
- gem sources --remove https://ruby.taobao.org/ 
// 2.等有反应之后再敲入以下命令
- gem sources -a https://gems.ruby-china.com
// 3.验证是否替换成功
- gem sources -l

我之前已经换过gem源了,直接查看验证了下

$ gem sources -l     //查看gem源 *** CURRENT SOURCES *** https://gems.ruby-china.com/

4,更新升级Gem版本

Gem是管理Ruby库和程序的标准包,如果它的版本过低也可能导致安装失败,解决方案升级Gem。

- sudo gem update --system

或者mac OS 10.11之后
sudo gem update -n /usr/local/bin —system

由于我之前是升级过的

$ sudo gem update -n /usr/local/bin —system  //因为我之前是换过的,执行如下
Password:
Updating installed gems
Nothing to update

5,安装cocoaPods

// 如果之前有
sudo gem uninstall cocoapods (移除原来的cocoapods)
// 安装CocoaPods(OS X 10.11以前)
- sudo gem install cocoapods
// 安装CocoaPods(10.11后苹果升级了安全策略)
- sudo gem install -n /usr/local/bin cocoapods

我操作之前已经删除了cocoaPods

$ sudo gem uninstall cocoapods
Gem 'cocoapods' is not installed


然后我重新安装

$ sudo gem install -n /usr/local/bin cocoapods

Fetching xcodeproj-1.15.0.gem
Fetching escape-0.0.4.gem
Fetching fourflusher-2.3.1.gem
Fetching gh_inspector-1.1.3.gem
Fetching ruby-macho-1.4.0.gem
Fetching cocoapods-1.9.1.gem


Successfully installed xcodeproj-1.15.0
Successfully installed escape-0.0.4
Successfully installed fourflusher-2.3.1
Successfully installed gh_inspector-1.1.3
Successfully installed ruby-macho-1.4.0
Successfully installed cocoapods-1.9.1


Parsing documentation for xcodeproj-1.15.0
Installing ri documentation for xcodeproj-1.15.0
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for fourflusher-2.3.1
Installing ri documentation for fourflusher-2.3.1
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.9.1
Installing ri documentation for cocoapods-1.9.1
Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 58 seconds
33 gems installed



最后安装成功会显示XX gems installed

6,然后执行 $ pod setup

$ pod setup   //执行 pod setup
Setup completed


$ pod --version  //查看cocoaPods版本
1.9.1



7,关于 pod setup

所有的项目的Podspec文件都托管在github.com/CocoaPods/S…第一次执行 pod setup时, CocoaPods会将这些podspec索引文件更新到本地的 ~/.cocoapods/目录下,这个索引文件比较大,有80M左右。所以第一次更新时非常慢。
一个叫akinliu的同学在gitcafe和oschina上建立了CocoaPods索引库的镜像,因为gitcafe和oschina都是国内的服务器,所以在执行索引更新操作时,会快很多。如下操作可以将CocoaPods设置成使用gitcafe镜像:

// 1.移除原有服务器
- pod repo remove master
如报错repo master does not exist 不必理会
// 2.添加境内服务器
(GitCafe 的服务已经从 201632 日 起合并至 Coding.net,2016531 日正式关停服务)
- pod repo add master https://gitcafe.com/akuandev/Specs.git

- pod repo add master http://git.oschina.net/akuandev/Specs.git(开源中国较慢)

- pod repo add master https://git.coding.net/CocoaPods/Specs.git

如果报
To setup the master specs repo, please run 'pod setup'

- pod repo update
换一种方式吧,方式如下


在git配置ok的前提下,直接将文件clone一份到本地。然后将文件夹名改为master,并将其拖到/Users/用户名/.cocoapods/repos目录下即可。

也可以直接用一条命令一步到位,直接跳过pod setup

git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master

这里有一个官方的 pod setup 解释 

感兴趣的同学可以看看。

8,cocoaPods的基本使用

cd 工程目录
// 搜索
pod search + 库名
vim Podfile
// 写完之后安装就ok 
 :wq 保存退出
pod install

// 要更新的话
pod update

// podfile 里需要写

source 'https://github.com/CocoaPods/Specs.git'  //这个是 CocoaPods 在 1.7 版本之后需要添加
target '项目名称' do
platform :ios, '9.0'
pod 'AFNetworking'
end


pod install --verbose --no-repo-update该命令只安装新添加的库,已更新的库忽略
pod update 库名 --verbose --no-repo-update该命令只更新指定的库,其它库忽略

当需要在CocoaPods中删除一个我们不要的库时 
可以在Podfile中直接删除相关库再cd 到项目目录 
执行pod update --verbose --no-repo-update 
或者pod install --verbose --no-repo-update命令

两者的删除时区别:
pod update --verbose --no-repo-update 
会在删除相关库时 更新其他库版本
pod update 库名 --verbose --no-repo-update 
只会删除相关库 和下方一致
pod install --verbose --no-repo-update 
只会删除相关库

两者的安装时区别:
pod install --verbose --no-repo-update 
只安装新添加的库
pod update --verbose --no-repo-update 
会在安装相关库时 更新其他库版本
pod update 库名 --verbose --no-repo-update 
只更新指定的库,其它库忽略

个人建议使用 先Podfile删除某个要升级的库,然后再添加,最后执行pod install --verbose --no-repo-update

9,cocoaPods不更新spec仓库 install / update

每次执行pod installpod update的时候,cocoapods都会默认更新一次spec仓库。这是一个比较耗时的操作。在确认spec版本库不需要更新时,给这两个命令加一个参数跳过spec版本库更新,可以明显提高这两个命令的执行速度。

其中--verbose的作用就是打印出执行过程中详细的信息,--no-repo-update的作用就是禁止更新repo,这样就避免执行了git fetch,从而加快速度。

pod install --verbose --no-repo-install
pod update --verbose --no-repo-update

# 后续遇到的问题

安装完成后,在一个项目下运行$ pod update –verbose –no-repo-update,出现问题

$ pod update --verbose --no-repo-update
Update all pods
  Preparing

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Fruits`: (``)

Finding Podfile changes
  - AFNetworking
  - CYLTabBarController
  - MBProgressHUD
  - MJExtension
  - MJRefresh
  - Masonry
  - SDWebImage
  - WMPageController

Resolving dependencies of `Podfile`

Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`
  CDN: trunk Relative path downloaded: CocoaPods-version.yml, save ETag:
  "04c48efc0cce3f97c1ebf74b677935d8-ssl-df"
  CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local
  because checking is only perfomed in repo update
  CDN: trunk Relative path downloaded: all_pods_versions_0_f_b.txt, save ETag:
  "409e17a56e5cae20f48f0ae1d33d75cc-ssl-df"
  CDN: trunk Redirecting from
  https://cdn.cocoapods.org/Specs/0/f/b/MJRefresh/0.0.1/MJRefresh.podspec.json
  to
  https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/0.0.1/MJRefresh.podspec.json
  CDN: trunk Redirecting from
  https://cdn.cocoapods.org/Specs/0/f/b/MJRefresh/1.0.4/MJRefresh.podspec.json
  to
  https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/1.0.4/MJRefresh.podspec.json
  CDN: trunk Redirecting from
  https://cdn.cocoapods.org/Specs/0/f/b/MJRefresh/1.0.3/MJRefresh.podspec.json
  to
  https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh ...中间省略N多
  
[!] Unable to find a specification for `MJRefresh`

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 setup 之前需要 执行,忘记了更新 repo,然后我执行 $ pod repo update

$ pod repo update
Updating spec repo `master`
  $ /usr/local/bin/git -C /Users/mqing/.cocoapods/repos/master fetch origin
  --progress
  remote: Enumerating objects: 11884, done.        
  remote: Counting objects: 100% (11884/11884), done.        
  remote: Compressing objects: 100% (213/213), done.        
  remote: Total 31199 (delta 11721), reused 11748 (delta 11655), pack-reused 19315        
  Receiving objects: 100% (31199/31199), 3.40 MiB | 507.00 KiB/s, done.
  Resolving deltas: 100% (21513/21513), completed with 3457 local objects.
  From https://github.com/CocoaPods/Specs
     70aace6bc84..15b6417a1ab  master     -> origin/master
  $ /usr/local/bin/git -C /Users/mqing/.cocoapods/repos/master rev-parse
  --abbrev-ref HEAD
  master
  $ /usr/local/bin/git -C /Users/mqing/.cocoapods/repos/master reset --hard
  origin/master
  Checking out files: 100% (337848/337848), done.
  HEAD is now at 15b6417a1ab [Add] WCBaseKit 0.1.0
Updating spec repo `trunk`

然后想当然的执行 $ pod update ,被自己的随意爆锤

$ pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
[!] CDN: trunk Repo update failed - 86 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/0.0.1/MJRefresh.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/1.0.3/MJRefresh.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/0/f/b/MJRefresh/1.0.4/MJRefresh.podspec.json Response: Couldn't connect to server

...省略N多

然后执行  $ pod install

$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 8 dependencies from the Podfile and 9 total pods installed.


# 遇到的问题:CDN: trunk URL couldn’t be downloaded: 

执行 pod search  xxx 或者 pod update 会出现该问题(其实上边的问题应该就是这个问题,但是我没明白为什么当时 pod install 会成功)

在 CocoaPods1.7 版本中开始引入 CDN 方式,并且在 1.7.2 中完成,目的是为了加快初始设置和依赖关系分析的速度。
CocoaPods官网

执行 pod repo remove trunk 如下

$ pod repo remove trunk
Removing spec repo `trunk`

然后执行 pod search AFNetworking 可以成功搜索

$ pod search AFNetworking
Setup completed

然后执行 pod update  会报错如下

$ pod update
Update all pods
Updating local specs repositories
Cloning spec repo `trunk` from `https://cdn.cocoapods.org/`
[!] Unable to add a source with url `https://cdn.cocoapods.org/` named `trunk`.
You can try adding it manually in `/Users/mqing/.cocoapods/repos` or via `pod repo add`.

解决办法:需要在 podfile 添加

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

然后执行 pod update

$ pod update
Update all pods
Updating local specs repositories
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

然后我把MAC连接到我的手机热点,重新执行 pod update

$ pod update

最后成功更新。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/13241.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注