简体   繁体   中英

Cannot access storyboard in resource bundle file inside iOS static library

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM