Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

framework with view controller and storyboard

Is it possible to create a cocoa touch framework in swift which contain storyboard and viewControllers?

If yes can you give me a reference to a guide or something to get started? all the examples i see of creating frameworks are very simple classes which don't involve ui

I want to create a framework which involve UI

like image 328
Michael A Avatar asked Jun 18 '15 11:06

Michael A


1 Answers

Yes, that is possible.

All you have to do is to create a cocoa framework as you normally do from File > New > iOS - Cocoa Framework..

Since this involves UI, Click on the project and right click > New > iOS - Storyboard. And after that it is just as simple as you do it in a normal app. Once your stuff is over in the framework side, you gotta create a new project to test your framework with UI (make sure that the class created in fw is a public class ).

To load the storyboard of your framework instead of your sample project's storyboard, do the full in ViewWillAppear method.

  • Create an object for storyboard along with the bundle (of your framework - normally it will be your VC's name)
  • instantiateInitialViewController
  • And present them

And you'll have your framework's storyboard in your sample project.

like image 178
user6502515 Avatar answered Oct 21 '22 23:10

user6502515