如何为可可豆荚正确配置我的项目? [英] How do I configure my project for Cocoa Pods correctly?

查看:76
本文介绍了如何为可可豆荚正确配置我的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我过去的一些项目中,Cocoa Pods的配置不正确,这会导致不良情况,例如需要在Project Navigator中重复Cocoa Pod项目,或者必须将Pod文件检入版本控制。



如何正确安装Cocoa Pods并验证目录结构和Project Navigator结构是否正确设置?

解决方案

使用Cocoa Pods的最佳方法是遵循。



4。添加的PODS_ROOT



您目标的构建设置来源于此:(注意:此滚动条一直向下滚动)





...对此:





请注意如何将 PODS_ROOT 添加为用户定义的设置。



注意:重新安装Pods时,配置的这一部分有时会出错,因此您可能需要关闭并打开Xcode项目进行修复。



5。其他更改



您可以看到完整的更改列表





In some of my past projects, Cocoa Pods wasn't configured correctly and it would lead to undesirable things such as needing duplicate Cocoa Pod projects in the Project Navigator, or pod files having to be checked in to version control.

How do I install Cocoa Pods correctly and verify that my Directory structure and Project Navigator structures are set up properly?

解决方案

The best way to use Cocoa Pods is to follow the official example's lead.

This consists of several steps.

Setting up Cocoa Pods for the first time

1. Install Cocoa Pods on your computer

Begin with the Getting Started Guide to install Cocoa Pods on your computer.

2. Create a Podfile

Do not create the Podfile in Xcode, since it should not be part of your project!

Create the file in your favorite text editor, and save it at the same level as your .xcodeproj file.

An example of a Podfile's contents are:

pod 'CupertinoYankee', '~> 1.0'

3. Run pod install

Navigate to your Podfile's directory in terminal and run pod install.

4. Open the generated workspace

Once you run pod install, you will see a message such as:

[!] From now on use MyProject.xcworkspace.

Close the Xcode project, and open up the generated .xcworkspace file.

Understanding the Changes

It is always useful to know what changes were made to your project in case things go wrong.

1. Directory structure

You should have started with a structure such as:

... then manually added a Podfile:

After running pod install, your directory structure now looks like this:

Notice how the only new objects are:

  • MyProject.xcworkspace
  • Podfile.lock
  • Pods

2. Project Navigator

In Xcode, you started with this:

... and ended with this in the new workspace:

For reference, here is an expanded look at the new directory structure:

Obviously, the Pods project was added to the Project Navigator, but there are a few other key things to notice:

Notice how Podfile is located at the root of the MyProject folder in Finder, but is inside of the Pods project in Xcode's project navigator.

Likewise, notice how Pods.xcconfig is located inside the Pods folder in Finder, but is inside of the MyProject in Xcode's project navigator.

3. Configurations

These are the same screenshots as before:

In Xcode, you started with this:

... and ended with this in the new workspace:

Notice how under Configurations, the "MyProject" target now has Pods specified.

This is important because otherwise PODS_ROOT will not be set up properly (among other things), and when you build, you will get errors.

4. PODS_ROOT added

Your target's Build Settings went from this: (Note: this is scrolled all the way down)

... to this:

Notice how PODS_ROOT was added as a User-Defined setting.

Note: this part of the configuration sometimes gets bugged out when reinstalling Pods, so you may need to close and open the Xcode project to fix it.

5. Other changes

You can see a complete list of the changes here.


这篇关于如何为可可豆荚正确配置我的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆