ios - 无法在现有的 Xcode 项目中安装 cocoaPods

标签 ios swift xcode installation cocoapods

我在 Xcode (swift 3) 中有一个现有项目,其中设计了详细的 UI。我仍然无法将 CocoaPods 安装到该项目中。

我看到的关于如何安装 cocoa pod 的所有指南人们创建一个新项目并将其安装在该新项目中,但是,我想将其安装在现有(设计的 UI)项目中。尝试在该项目中安装 cocoa pods 将我带到一个工作区,该工作区显示左侧各处的所有内容都是空的和红线,请查看屏幕截图并提出解决方案。谢谢!

Screenshot of workspace

最佳答案

请按照以下步骤将 pod 安装到现有项目:

打开终端并使用 cd 命令导航到包含您的项目的目录: cd ~/Path/To/Folder/Containing/Project

接下来,输入以下命令:

荚初始化

这会为您的项目创建一个 Podfile。 最后,键入以下命令以使用 Xcode 打开 Podfile 进行编辑:

打开-e pod文件

它会为您打开 podfile。

现在编辑 podfile 以添加所需的框架。它应该类似于下面的代码片段。

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectTarget' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
pod 'Firebase/Messaging'
  # Pods for ProjectTarget
  target 'ProjectTarget-iOSSDKTests' do
    inherit! :search_paths
    # Pods for testing
  end
  target 'ProjectTarget-iOSSDKUITests' do
    inherit! :search_paths
    # Pods for testing
  end
end

然后将 pod 集成到项目中并创建 .xcworkspace。

下次打开 .xcworkspace 以继续该项目。

关于ios - 无法在现有的 Xcode 项目中安装 cocoaPods,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45975406/

相关文章:

ios - 添加新的初始 UIViewController 之后 UINavigationController "acting crazy"

ios - 使用 Swift 4.2 解析嵌套 JSON

swift - 可扩展的表格单元格内容从单元格溢出

ios - NSDateComponentsFormatter 的方法 stringFromDate :ToDate: is returning a different value every second

ios - 通过presentViewController 在 View 之间移动。出了什么问题吗?

ios - 包含 3 个组的合适 View

ios - 旋转后的 CollectionView 布局

json - 使用 Swift JSON 从 TheMovieDB API 获取数据时遇到问题

swift - 即使 Swift 中的值相等,两个 Double 值的相等性如何始终为假?

ios - 更新约束菜单全部变灰