集成/安装 cocoapods 到现有的 xcode 项目,objective-c 或 swift
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36084956/
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
Integarte/Install cocoapods to existing xcode project, objective-c or swift
提问by swiftBoy
I was looking for integrating cocoapods to my existing xcode projects.
我正在寻找将 cocoapods 集成到我现有的 xcode 项目中。
I found these few post but they are based on issue instead my problem.
我找到了这几篇文章,但它们是基于问题而不是我的问题。
not able to acess installed pods framework
How to add cocoapods to existing workspace not project(this one is for work-space not project)
如何将 cocoapods 添加到现有工作区而不是项目(这个是针对工作区而不是项目)
Making a CocoaPod from an existing Xcode project(this one is more on integrating swift with objective c project)
从现有的 Xcode 项目制作 CocoaPod(这个更多是关于将 swift 与目标 c 项目集成)
So I spending quality time i did for my project. I am sharing step by step integration in my answer post.
所以我花了我为我的项目所做的优质时间。我正在我的回答帖子中分享一步一步的集成。
please feel free to suggest and improvement.
请随时提出建议和改进。
happy to learn and share
乐于学习和分享
回答by swiftBoy
Install CocoaPods on System
在系统上安装 CocoaPods
Step.1 Open Terminal and enter the following command:
Step.1 打开终端并输入以下命令:
sudo gem install cocoapods
sudo gem 安装 cocoapods
Create Podfile for Project
为项目创建 Podfile
Step.2 now you need to close Xcode.
Step.2 现在您需要关闭 Xcode。
Open Terminal at project's root folder
在项目的根文件夹中打开终端
Step.3 Next, enter below command to create podfile:
Step.3 接下来,输入以下命令来创建 podfile:
pod init
豆荚初始化
Edit podfile
编辑播客文件
Note: Make sure we will edit podfile with Xcode not TextEdit etc.
注意:确保我们将使用 Xcode 而不是 TextEdit 等编辑 podfile。
Step.4 Type this command to open the Podfile using Xcode for editing:
Step.4 输入此命令以使用 Xcode 打开 Podfile 进行编辑:
open -a Xcode Podfile
打开 -a Xcode Podfile
Step.5 update pode file as shown below screenshot, save and close.
Step.5 更新pode文件如下图所示,保存并关闭。
Install lib/framework
安装库/框架
Now we have added our required lib/framework pod command
现在我们已经添加了我们需要的 lib/framework pod 命令
pod 'SwiftForms'
let's go for install
让我们去安装
Step.5 Enter the following command in Terminal and hit Enter
Step.5 在终端中输入以下命令并按 Enter
pod install
吊舱安装
Result screen
结果画面
Thats it!! we have done.
就是这样!!我们已经做到了。
Open Project with pods
使用 Pod 打开项目
Now go to the project folder,we can see that CocoaPods created a new project_name.xcworkspace file and a Pods folder.
现在进入项目文件夹,我们可以看到 CocoaPods 创建了一个新的 project_name.xcworkspace 文件和一个 Pods 文件夹。
open project_name.xcworkspace with xcode
使用 xcode 打开 project_name.xcworkspace
your project structure should look like
你的项目结构应该是这样的