IOS Static Framework with resources inside

Andrei Stanescu picture Andrei Stanescu · Aug 29, 2012 · Viewed 22.8k times · Source

I'm trying to create a framework that keeps some common code I use around in my projects. I found online tutorials and managed to create a framework but I still have one problem related to resources (xibs, images, etc).

Let's say I have a MainViewController.xib which has a UIImageView using a test.png. All these are in my framework package.

When I use the framework in another project, I add it to the "Copy Bundle Resources" build phase. The problem is that the xib is only accessible using a path like dummy.framework/Resources/MainViewController.xib and the UIImageView inside can't load test.png.

It seems that the UIImageView will try to load the png from the root of the bundle, and not from the relative folder where the xib is also stored.

Has anybody managed to create a framework with code and resources and use it in another project?

Answer

Ryan Poolos picture Ryan Poolos · Oct 20, 2014

I know this is an old thread, but to keep new people from making the same mistakes here is a note:

As of Xcode 6 and iOS8, Apple has a fully supported first party Dynamic Framework solution built in. For more information look here: https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_6_0.html#//apple_ref/doc/uid/TP40014509-SW14

But the short of it is, create a new project and choose the Cocoa Touch Framework template.