如何组织依赖pod的框架项目?

时间:2017-11-14 15:52:00

标签: ios xcode frameworks

我们将创建一个框架项目(让我们将其命名为 F ),以便在几个iOS应用程序项目中共享。 F 取决于几个第三方框架(由Cocoa pod分发)。

决定 F 将作为 .framework (而非pod)分发。

我们的想法是应用只会包含 F 。应用程序的开发人员甚至不需要知道 F 在内部使用其他一些框架。

我们将创建一个测试项目(让我们将其命名为 T )以测试 F 表现良好。

问题是如何组织它?

通常,我会在Xcode中制作 T F 子项目:

T.xcodeproj
    F.xcodeproj

然后我开发 F ,对其进行测试并最终将 F.framework 分发给处理这些应用的人。

但是在这种情况下, F 取决于pods。在pod install之后,我得到F.xcworkspace。显然,我无法使项目依赖于工作空间:

T.xcodeproj???
    F.xcworkspace???

这是否意味着我无法将 T F 项目结合起来(这样可以更轻松地开发框架和测试应用 T 同时)

1 个答案:

答案 0 :(得分:1)

您应该能够将完整项目放在与您正在开发的框架相同的.xcodeproj中。我所做的是创建了一个示例应用程序(这里称为“TestRunner”),它将用于运行某些单元测试并在我的框架'.xcodeproj中显示一些基本功能作为目标。

通过这种方式,我们可以在同一个仓库中对框架和工作项目进行测试。这是结构的样子。

enter image description here

TestRunner是一个完整的应用程序,您可以在模拟器中运行并包含DCExtensions.framework。当我们构建DCExtension框架时,不包括TestRunner代码。我们安装的吊舱包括在内。

您的Podfile可能看起来像这样。

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'DCExtensions' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for DCExtensions
  pod 'Alamofire'

  target 'DCExtensionsTests' do
    inherit! :search_paths
    # Pods for testing

  end

end

target 'TestRunner' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TestRunner

end
相关问题