简体   繁体   中英

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 presentViewController:animated:completion ).

I see three options:

  1. Bundling .xib files for each UI (this will also make me use .xib 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM