I have an Xcode workspace with a couple of projects, say Foo and Baz, that both depend on some common code, which happens to be the RCSwitch switch button code (can be found here if anyone is interested). RCSwitch comes with a few image files that need to be loaded when Foo or Baz are running. They get loaded using the UIImage imageNamed: message, like so
UIImage *knobTmpImage = [[[UIImage imageNamed:@"btn_slider_thumb.png"] retain] autorelease];
My understanding is that for that to work the images need to be part of the application bundle. My question is how to get them there from within my library? I have tried adding the "Copy Bundle Resources" build phase to my library project and then adding all the images to that without any effect. The images do not get found at runtime.
Then I tried adding the images to the "Copy Bundle Resources" build phase of Foo and Baz themselves; one has to select "Add Others" as the upcoming dialog does not list any resources outside the current project. That actually works, but it does seem like a weird way of doing it. Neither Foo nor Baz ought to have knowledge of the internals of the library. What if I wanted to ship the library to external customers?
Is there another way of doing this? Is it even possible to have images or other resources in a libXXX.a file?
You can apply workaround to solve what you are after, but I would suggest you to create a framework rather a static library. Following articles might help you.
http://simplyitinc.blogspot.com/2011/04/creating-static-framework-in-xcode-4.html
http://www.cocoanetics.com/2010/05/making-your-own-iphone-frameworks-in-xcode/ – Learner Sep 02 '11 at 20:21