0

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 have a UIViewController with identifier OfferWallViewController in the storyboard: When I try to instantiate it inside the static library, I get the following error message:

Unknown class OfferwallViewController in Interface Builder file

The code for instantiating the UIViewController is as follows:

NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"OfferWallResources" withExtension:@"bundle"]];
    UIStoryboard *s=[UIStoryboard storyboardWithName:@"Offerwall" bundle:bundle];
    OfferwallViewController *o=[s instantiateViewControllerWithIdentifier:@"OfferwallViewController"];

I also made OfferwallViewController the initial UIViewController of the storyboard and tried using the following code:

OfferwallViewController *o=[s instantiateInitialViewController];

But, I am still facing the same issue when I am instantiating the UIViewController inside the static library.

I tried following the link: Xcode 6 Strange Bug: Unknown class in Interface Builder file But nothing happens when I press Enter inside the Module option of the given viewcontroller.

I am still not getting where I am going wrong. I am using Xcode 7.2.

Community
  • 1
  • 1

1 Answers1

0

It might not be detecting your static library as a Module.

A workaround can be to subclass OfferwallViewController in your current application and then use the subclass in storyboard.

PS: I guess static libraries are not meant to store resources like storyboards, xibs or images. You should use Xcode Frameworks.

Rahul Katariya
  • 3,528
  • 3
  • 19
  • 24
  • Kataria: Thats why I am using a resource bundle file 'OfferWallResources.bundle' where I have placed the storyboard file and the OfferWallViewController class files. – Anirban Bhattacharya Feb 04 '16 at 06:29