mllm mllm - 5 months ago 12
Objective-C Question

Deliver a Cocoapods Pod with UI

I was wondering about the best way to deliver a Cocoapods Pod with UI.
I need the users of my Pod to be able to initialise an instance of some entry point view controller, and then presenting it in their app (for example with


I see three options:

  1. Bundling
    files for each UI (this will also make me use
    files and not storyboards internally). This way the user initialises the first view controller and from there I take control.

  2. Bundling a whole storyboard, but then how do you expect the user to integrate it into their app?

  3. Building my UI programatically inside my Pod (like I saw Braintree do in their SDK).

Any thoughts?


Any of those options work just fine. If you choose to use xibs or storyboards you have to remember to include those files in your podspec like so:

  s.resources    = "Project/**/*.{png,jpeg,jpg,gif,storyboard,xib,lproj,xcdatamodeld,plist,xcassets}"

Also one thing to look out for is accessing your pod's bundle. It won't be the NSBundle.mainBundle() anymore since your pod doesn't have access to the main project's bundle. Instead you need to access the bundle for the class you are working in like so let podBundle = NSBundle(forClass: self)