我参考了许多链接并尝试了,但我没有成功。我阅读了CocoaPods文档,并多次尝试安装,但总是因为初始步骤而失败。我发现了一个错误,我不能先安装宝石。一个一个的步骤是什么?例如如何安装的步骤或演示。
这是我尝试过的一个链接。
截图指的是我得到的这个控制台错误:
我参考了许多链接并尝试了,但我没有成功。我阅读了CocoaPods文档,并多次尝试安装,但总是因为初始步骤而失败。我发现了一个错误,我不能先安装宝石。一个一个的步骤是什么?例如如何安装的步骤或演示。
这是我尝试过的一个链接。
截图指的是我得到的这个控制台错误:
当前回答
多亏了SwiftBoy的10步解决方案,我成功地使用CocoaPods设置了最新版本的AudioKit。
1. 使用Xcode创建MyAudioApp Swift项目,将其保存到我的开发者目录。
/Users/me/Developer/MyAudioApp
2. 使用Cocoapods在MyAudioApp项目中安装AudioKit(即安装AudioKit sdk)
3.打开终端,键入下面的命令并按Enter
sudo gem install -n /usr/local/bin cocoapods
4. 输入系统密码,按“Enter”
5. 在终端中,键入下面的命令并按Enter
cd /Users/me/Developer/MyAudioApp
6. 在下面的终端类型命令中创建项目pod文件并按Enter
touch Podfile
7. 在下面的终端类型命令中打开项目pod文件并按Enter(在TextEdit中打开)
open Podfile
8. 编辑下面的代码到打开的pod文件(并在退出TextEdit之前保存文件)
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.2'
use_frameworks!
target 'MyAudioApp' do
pod 'AudioKit', '~> 4.7'
end
9. 在下面的MyAudioApp工作空间类型Terminal命令中安装AudioKit并按Enter
Pod install
等待安装完成
10. 在Finder中,进入项目文件夹/Users/me/Developer/MyAudioApp 然后点击下面的。xcworkspace文件(在Xcode中打开!)
/Users/me/Developer/MyAudioApp/MyAudioApp.xcworkspace
11. 在MyAudioApp中编辑ViewController.swift并插入以下内容
import AudioKit
其他回答
这些是我通常遵循的完整步骤。我把这些步骤写得尽可能短,假设你了解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来使用您的库。
CocoaPods安装步骤:
打开终端:
sudo gem update --system
sudo gem install activesupport -v 4.2.6
sudo gem install cocoapods
pod setup
pod setup --verbose
然后用Terminal进入你的项目目录:
cd Your Project Path
然后在终端输入如下命令:
pod init
open -a Xcode Podfile
(编辑一个文件的豆荚和一个“天光”)
pod install
容器安装
Open terminal and type: sudo gem install cocoapods The Gem will get installed in Ruby inside the System library. Or try on Mac OS X v10.11 (El Capitan), type: sudo gem install -n /usr/local/bin cocoapods If there is an error "activesupport requires Ruby version >= 2.xx", then install latest activesupport first by typing in the terminal. sudo gem install activesupport -v 4.2.6 After installation, there will be a lot of messages. Read them and if no error found, it means the CocoaPods installation is done. Next, you need to setup the CocoaPods master repository. Type in the terminal: pod setup And wait it will download the master repository. The size is very big (370.0 MB in December 2016). So it can be a while. You can track of the download by opening Activity and go to the Network tab and search for "git-remote-https". Alternatively, you can try adding "--verbose" to the command like so: pod setup --verbose Once done, it will output "Setup Complete", and you can create your Xcode project and save it. Then in the terminal, cd to your Xcode project root directory (where your .xcodeproj file resides) and type: pod init Then open your project's podfile by typing in terminal: open -a Xcode Podfile Your Podfile will get open in text mode. Initially there will be some default commands in there. Here is where you add your project's dependencies. For example, in the podfile, type pod 'AFNetworking', '0.9.1' (This line is an example of adding the AFNetworking library to your project.) Other tips: Uncomment platform :ios, '9.0' Uncomment use_frameworks! if you're using Swift When you are done editing the podfile, save it and close Xcode. Then install pods into your project by typing in terminal: pod install or (For m1 chip) arch -x86_64 pod install Depending how many libraries you added to your podfile for your project, the time to complete this varies. Once completed, there will be a message that says "Pod installation complete! There are X dependencies from the Podfile and X total pods installed." Now close your Xcode project. Then locate and open the .xcworkspace Xcode project file and start coding. (You should no longer open the xcodeproj file.)
Pod安装在Mac OS X v10.11.2 (El Capitan)上出现错误:
安装cocoapods时出错: activesupport要求Ruby版本>= 2.2.2。
在得到这个错误后,我尝试了这个命令并重新安装。这对我很管用。
sudo gem install activesupport -v 4.2.6
现在尝试相同的pod安装命令
sudo gem install -n /usr/local/bin cocoapods