4

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

c_m_conlan
  • 189
  • 2
  • 11
  • wow freaky, i was just about to ask a similar question, im a bit stuck on how to get the app to see the storyboard in the framework. does your bundle sit inside the framework, or outside (aka is it part of the .a somehow?), my storyboard is only ever used within the framework itself (well trying to get it that way) – Fonix Nov 13 '13 at 14:08
  • My bundle sits outside the framework, as in separately from the .a file. It does however contain the storyboard which is sitting within the framework and they have inter-dependencies. – c_m_conlan Nov 13 '13 at 14:38
  • How do you mean the storyboard is only used with the framework? Sounds like that could be a workable solution for my problem.... – c_m_conlan Nov 13 '13 at 14:39
  • my app has sort of a plug-in message inbox that will be used in other apps, basically you will call a function and a viewcontroller will appear (that will come from the storyboard in the framework) the end developer wont have access to the frameworks storyboard or anything, just calling that function should transition to a new window, well thats what i hope to achieve, im sure facebooks sdk does something like that – Fonix Nov 13 '13 at 14:51
  • actually, just looking through facebooks sdk resource bundles, they only contain images, no xib's r storyboards... so i wonder if they used anything like that in their frameworks – Fonix Nov 13 '13 at 14:54
  • also im at the stage now with my bundles where im having your exact problem now, cant find the associated viewcontroller – Fonix Nov 13 '13 at 14:58
  • managed to get it to work! check my answer – Fonix Nov 13 '13 at 15:14

1 Answers1

9

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

Community
  • 1
  • 1
Fonix
  • 11,447
  • 3
  • 45
  • 74