我参考了许多链接并尝试了,但我没有成功。我阅读了CocoaPods文档,并多次尝试安装,但总是因为初始步骤而失败。我发现了一个错误,我不能先安装宝石。一个一个的步骤是什么?例如如何安装的步骤或演示。

这是我尝试过的一个链接。

截图指的是我得到的这个控制台错误:


当前回答

在macOS大苏尔工作

安装最新版本的brew (https://treehouse.github.io/installation-guides/mac/homebrew)

2 .然后使用“brew uninstall cocoapods”

3使用“brew install cocoapods”安装最新版本的cocoapods(你必须用github version https://github.com/CocoaPods/CocoaPods/releases/tag/1.11.2验证安装版本,它们必须匹配)

4 .用“brew link—overwrite cocoapods”覆盖cocoapods链接

5 .查看cocoapods的版本“pod——version”

你已经安装了最新版本的cocoapods

其他回答

这些是我通常遵循的完整步骤。我把这些步骤写得尽可能短,假设你了解Mac和Xcode项目。首先,打开终端,使用以下命令,每个命令后按enter键。

如果你还没有安装CocoaPods,输入以下命令:

sudo gem install cocoapods

现在请使用以下命令移动到您的Xcode项目目录,并将/您的Xcode项目目录路径替换为该目录的实际路径:

cd /Your Xcode Project Directory Path

下面是如何使用CocoaPods的说明。输入到终端的每个命令执行成功后,请等待一段时间。

Searching for pods in terminal: pod search networking (replace networking with which you want to search) Creating the pod file: pod init Opening the pod file: open -a Xcode Podfile Adding the pods: (After adding your pods you must save the podfile first and then head back to the terminal again.) target 'WebServiceUsingMantleAFNetworking' do # platform :ios, '8.0' //Choose your version of iOS pod 'AFNetworking', '~> 2.6.0’ end OR platform :ios, '8.0' pod 'AFNetworking' pod 'Mantle' pod 'LBBlurredImage' pod 'TSMessages' pod 'ReactiveCocoa' Installing the pods: pod install Check for updates of pods on existing project: pod outdated Update the existing pods: pod update Uninstall the Cocoapods from system: sudo gem uninstall cocoapods There is a complete tutorial for removing pods from your Xcode project on Stack Overflow. You can check on this following link for more info. How to remove CocoaPods from a project?

1-在你的机器上安装Cocoapods

$ sudo gem install cocoapods

$ pod setup --verbose

2-检查你的机器上是否安装了Cocoapods ?

$ pod—版本

3-进入你的项目目录,这里有.xcodeproj

$ pod init

在使用pod init后,一个额外的文件被添加到名为Podfile的文件夹中。

4-通过双击打开podfile和pods之间的目标和结束

5-使用命令安装Pod

pod install

当你运行pod install命令时,它会安装你写在pod文件中的所有pod。安装所需的命令后,打开项目目录,您将得到2个新文件。

首先是Podfile。每次运行pod install命令-下载并安装新的pod -它会在Podfile中为每个pod写入它已经安装的版本。锁文件。

第二个是。xcworkspace -> Xcode工作空间文件可以用作Xcode . xcodeproj项目的包装器或容器。

现在使用背景为白色的.xcworkspace来使用您的库。

Mac OS X v10.11 (El captain)

RVM安装ruby-2.2.2

RVM使用ruby-2.2.2。

Sudo gem install -n /usr/local/bin cocoapods . sh

你可以在macOS中通过Homebrew安装CocoaPods。

首先,打开您的终端,并运行以下代码(如果没有安装Homebrew,则用于安装):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

然后通过以下命令轻松安装CocoaPods:

brew install cocoapods

通常我们使用

sudo gem install cocoapods

解决方案,修复CocoaPods错误在Mac OS X v10.11 (El Capitan):

sudo gem install -n /usr/local/bin cocoapods
pod setup
cd /project path
pod init

在Podfile中,我们需要设置目标

# Podfile

platform :ios, '9.0'

use_frameworks!

# My other pods

target “Projectname” do

    pod 'MBProgressHUD', '~> 0.8'
    pod 'Reachability', '~> 3.1.1'
    pod 'AFNetworking', '~> 2.2'
    pod 'TPKeyboardAvoiding', '~> 1.2'

end

target 'ProjectnameTests' do
    testing_pods
end

target 'ProjectnameUITests' do
    testing_pods
end

在控制台终端

pod install