Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble using xib files in libraries

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
–f

Update

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 creating and shipping "a feature" with all it's parts above mentioned?

like image 269
flohei Avatar asked May 09 '10 09:05

flohei


1 Answers

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.

like image 70
Felixyz Avatar answered Nov 02 '22 18:11

Felixyz