我参考了许多链接并尝试了,但我没有成功。我阅读了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
其他回答
打开终端 如果你没有cocoapods,输入sudo gem install cocoapods 输入“cd /工程路径”,但要替换为实际工程路径 触摸podfile 使用以下命令之一打开podfile: open -e podfile以TextEdit或 在Xcode中打开pod文件 设置目标并添加GoogleMaps pod文件,如下所示: 目标“项目名称在这里”做 豆荚的GoogleMaps 结束 使用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.)
打开终端 在终端输入$ sudo gem install cocoapods命令 创建新的Xcode项目 导航到包含Xcode项目的目录。使用cd " ../directory-location/..或CD[拖放项目文件夹] 圆荚体安装
如果此提示错误,无法添加带有url的源..然后安装Xcode的命令行工具。再次,重新运行Pod安装命令。
这也将安装所有依赖项。
现在,在工作区中打开你的项目,即项目名称。xcworkspace而不是Project-Name.xcodeproj
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
这里是一个图像的所有步骤。请按照它正确,我相信你不会得到任何错误。
从如何安装CocoaPods和设置你的Xcode项目。
首先,检查是否必须安装命令行。
你可以打开Xcode,在菜单中导航到 Xcode→首选项→下载→组件。找到命令行工具并选择安装/更新。
如果你没有找到命令行工具,那么你需要在终端上写这个命令:
xcode-select --install
然后点击安装。
如果你已经安装了命令行工具,你需要选择你的Xcode目录(有时这些类型的问题是由于可用的Xcode版本不同造成的)
遵循这个步骤。
打开终端,执行如下命令: Sudo gem安装cocoapods 输入“admin”密码。这可能需要一段时间。几分钟后,它 将显示绿色信息,如果CocoaPods成功安装在您的 Mac机。 如果你在Xcode 6中出现任何错误,比如开发者路径 失踪。首先在终端运行这个命令: sudo xcode-select -switch /Applications/Xcode6。app(或你的XCodeName.app) 现在你可以用你的Xcode项目设置Pod了。
现在你必须安装吊舱。遵循这个步骤。
打开终端 更改目录到您的Xcode项目根目录(其中您的 ProjectName。放置Xcodeproj文件)。 pod设置:(设置CocoaPods主库) 如果成功,将显示:安装完成(只读访问)。所以, 一切都是你安排的。现在让我们做一些更明显的事情。让我们在Xcode项目中安装库。
现在你必须在你的项目中设置和更新与pod相关的库。
Steps to add-remove-update libraries in pod: Open Terminal Change directory to your Xcode project root directory. If your terminal is already running then there isn't any need to do this, as you are already at the same path. touch pod file open -e podfile (This should open a blank text file) Add your library names in that text file. You can add new names (library name), remove any name or change the version, e.g.: pod ’Facebook-iOS-SDK’ pod ’EGOTableViewPullRefresh’ pod ’JSONKit’ pod ‘MBProgressHUD NOTE: Use the (control + ”) button to add single quote at both end of library name. It should be shown as straight vertical line. Without control button it shall be added as curly single quote which will give error while installation of file. Save and close this text file. Now libraries are set up and you have to install/update it Go to your terminal again and run this command: pod install (to install/update these libraries in pod). You should see output similar to the following: Updating spec repo `master’ \ Installing Facebook-iOS-SDK \ Generating support files
设置完成。
注意:
如果你正确地一步一步地遵循了这整个过程,那么你可以在选择Xcode后直接触发pod更新命令,然后选择你的项目路径。并编写命令荚更新。
你也可以在这里检查命令行工具: