Tutorial :Packaging a Bundle with a static library


I have a static library that includes some xibs. These will basically be the same across projects. I'd like to include the xibs as part of the library. I can include their veiwcontrollers, reference these controllers in the calling project but then there isn't a xib to load. When I right click the xib in the library project, it can't be part of the target.

I thought about creating a CFPluginBundle but that creates a new project. I'd loose all of my IBOutlet and IBAction references. What is the best way to reuse xibs that also have outlets and actions to specific controllers?


Here more discussion about it: Can you reference Xib files from static libraries on the iPhone?


I had the same problem when I wanted to export my project as a library for other developers to use. I found the perfect solution to my view and it seems it will answer yours too.

There is an xcode plugin that allows you to build your project as a library which includes the resources as well.


I do not know the guys that built this plugin, but it works like a charm


I'm not sure what you mean by "include the xibs as part of the library", since static libraries can't have resources--but they also aren't shipped stand-alone, so they don't need to. If you just want code re-use for your own projects, you could keep the xibs where-ever you keep the static library, and just include the xibs in any project that uses the library.

If you go the CFPluginBundle route, you can make new bundle targets in an existing project; there's nothing magic about the templates, they just take care of making dummy files and turning on the right build settings. You can copy those into a new target in your existing project and it will work just fine. That said, I'm not sure what you mean about losing IBOutlet and IBAction references, since that information is part of the xib (and the class you are using in the xib), not the project.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »