2

I am creating a static library in iOS. I am using a storyboard file in it. In order to do so I have created a resource bundle file named 'OfferWallResources.bundle' in which I have added my storyboard file named 'Offerwall.storyboard'. I am trying to access the storyboard inside the static library using the following code:

NSBundle *bundle = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"OfferWallResources.bundle"];
    UIStoryboard *s=[UIStoryboard storyboardWithName:@"Offerwall" bundle:bundle];

But my app is crashing with the following error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Offerwall' in bundle NSBundle (loaded)'

I also tried to access the same storyboard file in the target project using the same code and it worked. But, I want to access it inside the library. I don't get where I am going wrong.

iAnurag
  • 9,286
  • 3
  • 31
  • 48

1 Answers1

0

I think you are not instantiating the bundle properly. Try with [NSBundle bundleWithPath:] or [NSBundle bundleWithURL:].

lluisgh
  • 325
  • 1
  • 6
  • I tried using [NSBundle bundleWithPath:]. Getting the following error now: Unknown class OfferwallViewController in Interface Builder file. This viewcontroller is present in my storyboard file and I am instantiating it in the library using the code: OfferwallViewController *o=[s instantiateViewControllerWithIdentifier:@"OfferwallViewController"]; – Anirban Bhattacharya Feb 02 '16 at 11:02
  • And in the storyboard you have a view controller with the class set to OfferWallViewController and the identifier to "OfferwallViewController"? Anyway, this is another problem, getting the storyboard file seems to be working. – lluisgh Feb 02 '16 at 11:07
  • How to deal with the second problem? – Anirban Bhattacharya Feb 02 '16 at 11:14
  • Check this: http://stackoverflow.com/questions/24924966/xcode-6-strange-bug-unknown-class-in-interface-builder-file – lluisgh Feb 02 '16 at 11:49
  • And btw, set the answer as correct if it fixed the problem :) – lluisgh Feb 02 '16 at 11:50