Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - Linking framework storyboard to ViewController for use in main project

I am attempting to pull through and use a storyboard in my main project which is being created in a framework. This is to use the framework in a multitude of different projects going forward.

I have managed, using a bundle, to feed the storyboard through to the main project and I can see it when I build the app. However the appending ViewController, also sitting within the framework, does not link during runtime. All the classes in the framework are being imported to the main project.

The error message says that it cannot find the view controller.

I have attempted adding the view controller to the bundle, however it does not like this as it will not allow the .h file into a bundle. I have also tried inverting the dependencies so the framework become a dependency of the bundle (thinking was that it would cause all the classes therein, inc my viewcontroller, to load first).

Has anyone encountered this before? I would much appreciate suggestions for a fix!!

Thanks, Chris

like image 345
c_m_conlan Avatar asked Jan 11 '23 22:01

c_m_conlan


1 Answers

To get it to find the view controller associated, all you need is -all_load -ObjC in your apps Other Linker Flags in Build Settings.

it seems the linker leaves out the files necessary due to the apps code not actually using or referencing the ViewController, so the linker just leaves it out. This forces it to use the ViewController when linking now. (have a look at this answer for more detail)

i did this with just having my frameworks storyboard in a bundle along side my framework, i followed this guide for finding out how to make the bundle for the framework

like image 173
Fonix Avatar answered Jan 17 '23 17:01

Fonix