Universal static library with resources

Is it possible to create universal static libraries with resources(like images and xib files). I created static library with images and xib files in it and it is working good. But i need to create ".a" file. So that I can import .a file and use in multiple projects.

I generated ".a" file using lipo command but that doesn't worked. Please give any suggestion for generating .a file with xib files and images. Thanks in advance.,

Upvotes: 0

Views: 1700

Answers (1)

neilco
neilco

Reputation: 8012

In order to package images and XIBs with a static library, you have to create a resource bundle.

  1. Add a new target to your static library project. Select Bundle from OS X > Framework & Library.
  2. In your new bundle target's build phases, remove the Compile Sources and Link Binary With Libraries phases. Drag your images and XIBs to the Copy Bundle Resources build phase.
  3. In your bundle target's build settings, change the Base SDK from Latest OS X to Latest iOS.
  4. Edit your static library scheme. Select Build on the left. In the targets window, click the + button and add your bundle target. This will then ensure your resource bundle is built every time your build your static library.

You will need to change the code in your static library to load the XIBs and images from the resource bundle, rather than from the main bundle.

Add the resource bundle to the Copy Bundle Resources build phase in your target application and link the app against the static library.

Upvotes: 2

Related Questions