mattjgalloway
mattjgalloway

Reputation: 34912

UIViewController XIB in iOS framework or dependent project

I know this sort of question has been banded about before but I've not found the one definitive answer to the question I'm facing myself with at the moment. And that is within a library, how best to ship a UIViewController subclass with a complex view?

The methods I can see are:

  1. Ship the XIB as well and ask that users of your code add it to their project. This is undesirable in my opinion as it makes maintenance a nightmare. If you add a view controller to your library project then you have to add the new XIB to each and every project which uses the library.

  2. Create your view in loadView / viewDidLoad and take the pain of doing everything manually in there. This could be extremely complex though for complex view hierarchies.

  3. Somehow generate your loadView code from your XIB at compile time. Sounds complex to get something that would do this properly though.

What I don't quite understand is how Apple do it. With the MessageUI framework for example, there is MFMailComposeViewController which is a pretty complex view but there's no XIB for it (or at least not that I know of anyway - maybe there actually is?). I'd be interested to know how Apple do it - does anyone know?

Upvotes: 2

Views: 702

Answers (1)

user529758
user529758

Reputation:

They're coding everything from scratch, manually, which is, in my opinion, is the best choice. Sometimes InterfaceBuilder can really hijack your porject by applying unkown/badly documented settings etc., plus the code is less portable. For example, one with an unofficial toolchain for Linux, for example, might be unable to use the library without Interface Builder. Code has to be written by the developer, be able to be compiled with just a proper, but minimalistic toolchain (compiler+assembler+linker), without being dependent on any IDEs, SDKs or other technologies not strictly belonging to the programming part of one's project.

Upvotes: 2

Related Questions