整合/安装cocoapods到现有的xcode项目,objective-c或swift

时间:2023-01-24 07:30:09

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

无法访问已安装的pods框架

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与Objective 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

乐于学习和分享

1 个解决方案

#1


40  

Install CocoaPods on System

在系统上安装CocoaPods

Step.1 Open Terminal and enter the following command:

步骤1打开终端并输入以下命令:

sudo gem install cocoapods

sudo gem安装cocoapods


Create Podfile for Project

为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

pod init


Edit podfile

编辑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文件,如下图所示截图,保存并关闭。

整合/安装cocoapods到现有的xcode项目,objective-c或swift

Install lib/framework

安装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

步骤5在终端输入以下命令,然后按Enter键

pod install

pod安装

Result screen

结果屏幕

整合/安装cocoapods到现有的xcode项目,objective-c或swift

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

你的项目结构应该是这样的

整合/安装cocoapods到现有的xcode项目,objective-c或swift

#1


40  

Install CocoaPods on System

在系统上安装CocoaPods

Step.1 Open Terminal and enter the following command:

步骤1打开终端并输入以下命令:

sudo gem install cocoapods

sudo gem安装cocoapods


Create Podfile for Project

为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

pod init


Edit podfile

编辑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文件,如下图所示截图,保存并关闭。

整合/安装cocoapods到现有的xcode项目,objective-c或swift

Install lib/framework

安装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

步骤5在终端输入以下命令,然后按Enter键

pod install

pod安装

Result screen

结果屏幕

整合/安装cocoapods到现有的xcode项目,objective-c或swift

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

你的项目结构应该是这样的

整合/安装cocoapods到现有的xcode项目,objective-c或swift