Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using iOS static library common view controller in storyboard?

We are in the process of creating a set of common components and common views that are reusable across several applications we have. In these libraries we have the .xib files and view controllers. We want to be able to use these in storyboards for the specific applications. Is this even possible?

I haven't seen an easy way to share reusable views or components from static libraries in storyboards yet.

Whats the recommended way to do this to keep from having code duplicated in every project?

Thanks..

like image 305
jlgaustin Avatar asked Jun 20 '12 15:06

jlgaustin


1 Answers

Typically when making a static library for sharing, you can also include a bundle with resources (xib and image files for instance). Take a look at the FacebookSDK for instance. It contains a bundle with images and strings. Those can be loaded by the SDK code or the client app of the SDK.

For help on making a static lib with resources, see : https://github.com/jverkoey/iOS-Framework (thanks @jnjosh) or https://github.com/kstenerud/iOS-Universal-Framework. I've used the iOS-Universal-Framework on a shipping app recently. Works well.

In order to use xib files with storyboards, you can take one of two approaches:

  • Load the xib View Controllers in an action or segue called by the VC in the storyboard.

  • Or use the xib within the storyboard. See: Using XCode storyboard to instantiate view controller that uses XIB for its design

Also if it's just for internal use, I recommend simply making a shared repository of code + resources, rather than making a static library. The main benefit of the static library is ease of distribution outside of your team.

like image 113
Jess Bowers Avatar answered Oct 20 '22 01:10

Jess Bowers