iOS:cocoa Pods:如何向现有 Pod 添加新的依赖项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19330521/
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
iOS: cocoa Pods: How do I add a new dependency to an existing pod?
提问by Beau D'Amore
I have juuuust started with Cocoa Pods.
我 juuuust 从 Cocoa Pods 开始。
I have this workspace now after initially experimenting and getting AFNetworking successfully connected via this Ray Wenderlich tutorial.
在最初尝试并通过这个 Ray Wenderlich 教程成功连接 AFNetworking 之后,我现在有了这个工作区。
I want to now add in more dependencies like core-plot specifically. I found this link to a 'PodSpec' of Core-Plot
我现在想特别添加更多依赖项,例如 core-plot。我找到了指向 Core-Plot 的“PodSpec”的链接
Problem is, I have no idea how to further implement this... Anyone have a quick run-down of what to mod and what commands in terminal to run?
问题是,我不知道如何进一步实现这一点......任何人都可以快速了解要修改的内容以及终端中要运行的命令?
回答by Anupdas
You need to add the pod in Podfile and do pod install from terminal that's it. The steps can be summarized as
您需要在 Podfile 中添加 pod 并从终端进行 pod install 就是这样。步骤可以概括为
- In terminal change the directory to your project directory containing *.xcodeproj
- Run open Podfile. Which opens the Podfile in textEdit.
- Add pod'CorePlot', '~> 1.4'to it and save.
- Run pod install-- NOTE* that is **pod updateif already installed.
- 在终端中,将目录更改为包含 *.xcodeproj 的项目目录
- 运行open Podfile。这会在 textEdit 中打开 Podfile。
- 添加 pod'CorePlot', '~> 1.4'并保存。
- 运行pod install--注意* 即 **pod update如果已经安装。
You are good to go.
你已准备好出发。
回答by Jasper Blues
After you have initially installed CocoaPods into your project, you can add new dependencies (or remove unused ones) by editing the Podfile. Then simply run pod install again.
在您最初将 CocoaPods 安装到您的项目中后,您可以通过编辑 Podfile 添加新的依赖项(或删除未使用的依赖项)。然后只需再次运行 pod install 即可。
If you use AppCode it has nice integrated support, so that it can update Pods for you, just edit the Podfile in AppCode, and it will suggest for you to add the new dependencies.
如果您使用 AppCode,它有很好的集成支持,因此它可以为您更新 Pod,只需在 AppCode 中编辑 Podfile,它就会建议您添加新的依赖项。
Edit:
编辑:
In fact, run pod install
again after adding new pods, not update.
实际上,pod install
添加新 pod 后再次运行,而不是 update。
回答by Vivek Sehrawat
Simply run below command
只需运行以下命令
pod update
回答by santosh
Go to ur project folder and open terminal and set the project source to the terminal
转到您的项目文件夹并打开终端并将项目源设置为终端
-> Run open Podfile. Which opens the Podfile in textEdit.
-> Add pod'CorePlot', '~> 1.4' to it and save.
-> Run pod install -- NOTE(if u want to update all podfile then run pod update)
回答by RyanTCB
For the benefit of any pod noobs like me.
为了像我这样的豆荚菜鸟。
To update a pod file in Xcode project.
更新 Xcode 项目中的 pod 文件。
First close xCode.
首先关闭xCode。
open terminal
打开终端
type
类型
sudo gem
Then when prompted enter your systems password
然后在提示时输入您的系统密码
Next cd into the directory where you have your project and the podfile.
接下来 cd 进入您拥有项目和 podfile 的目录。
note* if your folder name has special characters like an "&" type the first part and press the Tab key. Terminal will auto complete and escape the special characters for you :-)
注意* 如果您的文件夹名称包含特殊字符,例如“&”,请键入第一部分并按 Tab 键。终端将自动完成并为您转义特殊字符:-)
Once inside your project folder where you have the podfile
一旦进入您拥有 podfile 的项目文件夹
type
类型
pod update
Thats it. Wait for terminal to finish and voila.
就是这样。等待终端完成,瞧。
Additional tips for terminal noobs
To list the files in a folder type ls
To re-enter a previous command use the up down arrow on your keyboard
给终端新手的额外提示
要列出文件夹中的文件,请键入 ls
要重新输入上一个命令,请使用键盘上的向上向下箭头
回答by Beau D'Amore
FYI: as per this link in google groups, 1.4 may be the problem in cocoa pods
仅供参考:根据谷歌群组中的这个链接,1.4 可能是可可豆荚的问题
I tried:
我试过:
pod 'CorePlot', '1.3'
and it compiles... it must be a problem with 1.4 and cocoa pods
它编译了......它一定是1.4和可可豆荚的问题