How to organize a framework project which depends on pods?

Viewed 478

We are going to create a framework project (let's name it F) to be shared along a couple of iOS app projects. F depends on several third-party frameworks (distributed by Cocoa pods).

It is decided that F will be distributed as a .framework (not as pod).

The idea is that apps will only include F. Developers of the apps does not even need not to know that F internally uses some other frameworks.

We will create a test project (let's name it T) to test that F behaves well.

The question is how to organize it?

Normally, I would make F subproject of T in Xcode:

T.xcodeproj
    F.xcodeproj

Then I develop F, test it and eventually distribute F.framework to guys working on the apps.

But is this case, F depends on pods. After pod install I get F.xcworkspace. Obviously, I cannot make project dependent on workspace:

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

Does it mean that I cannot combine the T and F projects (which would make it easier to develop both the framework and test app T simultaneously)

1 Answers

You should be able to put a full project in the same .xcodeproj as your framework you are developing. What I did was created a sample app (Here it's called "TestRunner") that would be used to run some unit tests and show some basic functionality as a target in my frameworks' .xcodeproj.

This way we have the tests for the framework and a working project with it in the same repo. Here is what the structure looks like.

enter image description here

TestRunner is a full app that you can run in the simulator and includes DCExtensions.framework. When we go to build the DCExtension framework, the TestRunner code is not included. The pods we have installed are included.

Your Podfile might look something like this.

# 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
Related