I'm having some trouble working with libraries and included xib files. Let me explain my situation first. I've got a project that's running pretty good. Now I need a part of my project as a library for another customer who want's to use some of the functionality in his app. I've created a library with help of that highly recommended article.
My customer should be able to initialize a main view controller like this:
LibraryMainViewController *lmvc = [[LibraryMainViewController alloc] initWithNibName:@"LibraryMainViewController.xib" bundle:foo];
That for sure leads to an error when I try to present that view controller modally. I'm not sure what bundle I have to use here. I tried something like
[NSBundle bundleForClass:[SomeClassInTheLibrary class]];
but that didn't solve the problem.
I would be glad if someone could tell me how to actually use a xib file in that kind of situation.
Thanks
–fUpdate
Ok, I see I got it wrong somehow. Just for clarification: What I need is the library, the headers and the additional resources, right? Is there some kind of best practice for crea开发者_StackOverflowting and shipping "a feature" with all it's parts above mentioned?
Static libraries can't include graphics, sounds, xibs or even headers. Only object code. Even if you added the xibs to Copy Bundle Resources, they won't become a part of the object file. Unfortunately, you can't use dynamic libraries or frameworks on the iPhone. See my answer here for a suggestion of how to create a separate assets bundle. You could also just send your customer the xib files separately, but then they have to replace them by hand if they change in the future.
Try without adding the extension to the XIB file. That's the way i usually do it. I'm also not sure if the XIB must be compiled to a NIB..
NSBundle *bundle = [NSBundle bundleForClass:[SomeClassInTheLibrary class]];
LibraryMainViewController *lmvc = [[LibraryMainViewController alloc] initWithNibName:@"LibraryMainViewController" bundle:bundle];
精彩评论