ios 更新到最新版本的 CocoaPods?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39481636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 10:07:59  来源:igfitidea点击:

Updating to latest version of CocoaPods?

iosswiftxcodecocoapods

提问by Barkley

I'm having some issues installing Alamofire 4.0into my project.

我在安装Alamofire 4.0到我的项目中时遇到了一些问题。

I've got the latest version of Xcode, running Swift 3, and when I try to install alamofire I'm getting like 800 compiler errors.

我有最新版本的Xcode,运行Swift 3,当我尝试安装 alamofire 时,我遇到了 800 个编译器错误。

Apparently

显然

CocoaPods 1.1.0+ is required to build Alamofire 4.0.0+

构建 Alamofire 4.0.0+ 需要 CocoaPods 1.1.0+

I looked at the version of CocoaPods I have in terminal and it says I'm at 1.0.1.

我查看了终端中的 CocoaPods 版本,它说我在 1.0.1。

Running an update didn't work I guess because CocoaPods1.1 is in beta.

我猜运行更新没有用,因为CocoaPods1.1 处于测试阶段。

So I'm not exactly sure how to update it up to where I'm good to go. Unless being out of date doesn't force like 800 compiler errors? Does that sound like some other issue?

所以我不确定如何将它更新到我可以去的地方。除非过时并不会强制出现 800 个编译器错误?这听起来像其他问题吗?

回答by user3899562

Execute the following on your terminal to get the latest stable version:

在您的终端上执行以下操作以获得最新的稳定版本

sudo gem install cocoapods

Add --preto get the latest pre release:

添加--pre以获取最新的预发布:

sudo gem install cocoapods --pre

回答by Dheeraj D

Open the Terminal->copybelow command

打开Terminal->copy下面的命令

sudo gem install cocoapods

It will install the latest stable version of cocoapods.

它将安装最新的稳定版本cocoapods

after that, you need to update pod using below command

之后,您需要使用以下命令更新 pod

pod setup

You can check pod version using below command

您可以使用以下命令检查 pod 版本

pod --version

回答by x0 z1

If you got System Integrity Protectionenabled or any other permission write error, which is enabled by default since macOS Sierra release, you should update CocoaPods, running this line in terminal:

如果您启用了系统完整性保护或任何其他权限写入错误(自 macOS Sierra 发布以来默认启用),您应该更新 CocoaPods,在终端中运行以下行:

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

After installing, check your pod version:

安装后,检查您的 pod 版本:

pod --version

You will get rid of this error:

您将摆脱此错误:

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

And it will install latest CocoaPods:

它将安装最新的 CocoaPods:

Successfully installed cocoapods-x.x.x
Parsing documentation for cocoapods-x.x.x
Installing ri documentation for cocoapods-x.x.x
Done installing documentation for cocoapods after 4 seconds
1 gem installed

回答by Sanzio Angeli

If you are using Homebrew, open terminal and type:

如果您使用的是 Homebrew,请打开终端并输入:

brew upgrade cocoapods

If that does not work, try:

如果这不起作用,请尝试:

brew install cocoapods

回答by Paulo Mattos

For those with a sudo-less CocoaPods installation(i.e., you do notwant to grant RubyGems admin privileges), you don't need the sudocommand to update your CocoaPods installation:

对于那些具有须藤少的CocoaPods安装(即你希望授予RubyGems的管理员权限),你不需要sudo命令来更新您的CocoaPods安装:

gem install cocoapods

You can find out wherethe CocoaPods gem is installed with:

你可以找出其中的宝石的CocoaPods安装有:

gem which cocoapods

If this is withinyour home directory, you should definitely run gem install cocoapodswithout using sudo.

如果它您的主目录中,您绝对应该在gem install cocoapods不使用sudo.

Finally, to check which CocoaPods you are currently running type:

最后,要检查您当前正在运行的 CocoaPods,请键入:

pod --version

回答by Jayprakash Dubey

Below are steps to update cocoapods :

以下是更新 cocoapods 的步骤:

  1. Open terminal(Shortcut : Press cmd + space tabto open Spotlight then text in terminal)
  2. Use command sudo gem install cocoapods. This will ask for system password due to security concern thereafter it installs gems
  1. 打开终端(快捷方式:Press cmd + space tab打开 Spotlight 然后输入文本terminal
  2. 使用命令sudo gem install cocoapods。出于安全考虑,这将要求输入系统密码,然后安装 gems

Screenshot 1

截图 1

  1. Now, set up pod using pod setupcommand. This will setup cocoapods master repo.
  1. 现在,使用pod setup命令设置 pod 。这将设置 cocoapods 主存储库。

Screenshot 2

截图 2

  1. You can check the version of cocoapods using pod --versioncommand.
  1. 您可以使用pod --version命令检查 cocoapods 的版本。

Screenshot 3

截图 3

回答by Kashif Ahmed

You can solve this problem by simply Commands:

您可以通过简单的命令来解决这个问题:

First:

第一的:

sudo gem install cocoapods

Desp:type user mac password now your cocoapods will be replace with a stable version.

Desp:输入用户 mac 密码,现在您的 cocoapods 将被替换为稳定版本。

if you have cloned the repo then type this command:

如果您已经克隆了 repo,请输入以下命令:

pod repo update

close your xcode and run this command

关闭您的 xcode 并运行此命令

Pod install

回答by Prakhar Prakash Bhardwaj

This is a really quick & detailed solution

这是一个非常快速和详细的解决方案

Open the Terminal and execute the following to get the latest stable version:

打开终端并执行以下操作以获得最新的稳定版本:

sudo gem install cocoapods

Add --pre to get the latest pre release:

添加 --pre 以获取最新的预发布:

sudo gem install cocoapods --pre

Incase any error occured

万一发生任何错误

Try uninstall and install again:

尝试卸载并重新安装:

sudo gem uninstall cocoapods
sudo gem install cocoapods

Run after updating CocoaPods

更新 CocoaPods 后运行

sudo gem clean cocoapods

After updating CocoaPods, also need to update Podfile.lock file in your project.

更新 CocoaPods 后,还需要更新项目中的 Podfile.lock 文件。

Go to your project directory

转到您的项目目录

pod install

回答by supersabbath

I tried updating and didn't work. Finally , I had to completely remove (manually )cocoapods, cocoapods-core , cocoapods-try.. any other package use by cocoa pods. Use this terminal command to list all the packages : gem list --local | grep cocoa pods

我尝试更新但没有用。最后,我必须完全删除(手动)cocoapods、cocoapods-core、cocoapods-try.. 可可豆使用的任何其他包。使用此终端命令列出所有软件包:gem list --local | grep cocoa pods

After that , I also delete ./cocoapods folder from user root folder.

之后,我还从用户根文件夹中删除了 ./cocoapods 文件夹。

回答by Muhammad Ali

Non of the above solved my problem, you can check pod version using two commands

以上都没有解决我的问题,您可以使用两个命令检查 pod 版本

  1. pod --version
  2. gem which cocoapods
  1. pod --version
  2. gem which cocoapods

In my case pod --versionalways showed "1.5.0" while gem which cocopodsshows Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.0/lib/cocoapods.rb. I tried every thing but unable to update version showed from pod --version. sudo gem install cocopodsresult in installing latest version but pod --versionalways showing previous version. Finally I tried these commands

在我的情况下pod --version总是显示“1.5.0”而gem which cocopods显示 Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.0/lib/cocoapods.rb. 我尝试了所有事情,但无法更新从pod --version. sudo gem install cocopods导致安装最新版本但pod --version始终显示以前的版本。最后我尝试了这些命令

  1. sudo gem update
  2. sudo gem uninstall cocoapods
  3. sudo gem install cocopods
  4. pod setup``pod install
  1. sudo gem update
  2. sudo gem uninstall cocoapods
  3. sudo gem install cocopods
  4. pod setup``pod install

catch for me was sudo gem update. Hopefully it will help any body else.

对我来说是 sudo gem 更新。希望它会帮助任何其他机构。