无法安装Cocoapods - 项目目录中找不到podfile [英] Cannot Install Cocoapods - No podfile found in the project directory
问题描述
我下载了一个示例项目,以了解如何创建UIPageViewController,我试图实际上分叉该项目并需要添加第三方库。现在,它看起来我的项目中没有.xcworkspace文件。当我尝试安装cocoapods时,我首先运行
I downloaded a sample project to learn how to make a UIPageViewController, and I am trying to essentially fork that project and need to add a third-party library. Right now, it does not look like I have a .xcworkspace file in my project. When I try and install the cocoapods, I first run
sudo gem install cocoapods
- 在特定的项目目录中我的终端
sudo gem install cocoapods
- in the specific project directory in my terminal
pod install
- 在同一目录中
pod install
- in that same directory
我在终端项目目录中找不到podfile时收到错误。
I am receiving an error in the terminal "No podfile found in the project directory."
这是否因为我没有.xcworkspace文件而发生?我是否正确安装了podfile?
Is this happening because I don't have a .xcworkspace file? Am I installing the podfile correctly?
< img src =https://i.stack.imgur.com/6wV1K.pngalt =在此处输入图像说明>
推荐答案
添加CocoaPods以管理项目中的依赖项的步骤:
Steps to add CocoaPods to manage dependencies in your project:
-
sudo gem install cocoapods
- >这会将CocoaPods安装为你机器上的一块
软件。
sudo gem install cocoapods
-> This installs CocoaPods as a piece of software on your machine.
转到项目目录的根目录并执行 pod init
- >
这将为您的项目添加一个基本Podfile。
Go to the root of your project directory and execute pod init
->
This will add a base Podfile to your project.
通过编辑将此外部依赖项添加到此Podfile中。
Add the external dependencies that you have to this Podfile by editing it.
运行 pod install
将获取您提到的所有外部依赖项
,并将其与项目
的 .xcworkspace
文件关联。如果您已经没有
,那么将为您生成 .xcworkspace
文件。
Run pod install
which will fetch all the external dependencies
mentioned by you, and associate it with a .xcworkspace
file of
your project. This .xcworkspace
file will be generated for you if
you already do not have one.
从这里开始,您应该使用 .xcworkspace
文件而不是 .xcproject
。
From here on, you should use .xcworkspace
file instead of .xcproject
.
target 'MyApp' do
pod 'AFNetworking', '~> 3.0'
end
其中 AFNetworking
是pod, 3.0
是我要安装的特定版本。
Where AFNetworking
is the pod and 3.0
is the specific version that I want to install.
文档:使用CocoaPods
这篇关于无法安装Cocoapods - 项目目录中找不到podfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!