Problem using xib files in libraries

I'm having problems working with libraries and the xib files are included. Let me explain my situation first. I have a project that works very well. Now I need part of my project as a library for another client who wants to use some functions in their application. I created a library using which recommended an article .

My client should be able to initialize the main view controller as follows:

LibraryMainViewController *lmvc = [[LibraryMainViewController alloc] initWithNibName:@"LibraryMainViewController.xib" bundle:foo]; 

This definitely leads to an error when I try to present this view controller modulo. I am not sure which package I should use here. I tried something like

 [NSBundle bundleForClass:[SomeClassInTheLibrary class]]; 

but this did not solve the problem.

I would be happy if someone could tell me how to actually use the xib file in such a situation.

thanks
-f

Update

Well, I see that I was somehow mistaken. Just to clarify: I need a library, headers and additional resources, right? Is there any best practice for creating and delivering a β€œfunction” with all of its parts mentioned above?

+6
objective-c uiviewcontroller bundle
source share
2 answers

Static libraries cannot include graphics, sounds, xib, or even headers. Object code only. Even if you added xibs to Copy Bundle Resources, they will not become part of the object file. Unfortunately, you cannot use dynamic libraries or frameworks on iPhone. See my answer here for a suggestion on how to create a separate asset package. You can also just send your client xib files separately, but then they must replace them manually if they change in the future.

+6
source share

Try without adding the extension to the XIB file. This is how I usually do it. I am also not sure if the XIB should be compiled into the NIB.

 NSBundle *bundle = [NSBundle bundleForClass:[SomeClassInTheLibrary class]]; LibraryMainViewController *lmvc = [[LibraryMainViewController alloc] initWithNibName:@"LibraryMainViewController" bundle:bundle]; 
0
source share

All Articles