Can you reference Xib files from static libraries on the iPhone?

No it isn't possible, because a static library is not the same as a "bundle".

A bundle is a directory that may contain all manner of files including resource files (xib), executable files and static libraries. It exists on the filesystem as a group of individual files.

A static library is a single file that contains classes, code and variables that were linked together by the library creator. It does not "contain" other files, it is essentially a database of compiled code.

Although it would be possible to put the data for the xibs in there, Xcode would have no way of knowing that it was in there, as it looks for them as individual files on the filesystem.

In Mac OS, you may create a "Framework" which is essentially a bundle of code, resources, settings etc which may be reused by multiple projects. However, Apple does not seem to support custom framework creation for iPhone OS.

Bundles https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1

Static Libraries http://en.wikipedia.org/wiki/Static_library


Reply to comment (won't fit in comment box)

No worries, I've been trying to do pretty much the same thing as you for the last week - I'd like to ship a "framework" of xibs, include files and .a libs to a client without giving them all the source code. I couldn't find a good way to do this with bundles either.

For whatever reason, Apple are being particularly obtuse about this - I can't see a reason for them to be so in the case of static libraries (dynamic libraries fair enough).

My solution for now is to manually create a package folder "Foo" that contains the following subfolders:

  1. "include" -> put .h files here
  2. "res" -> put .xib files here
  3. "lib" -> contains "iphoneos" & "iphonesimulator" subfolders each with libFoo.a

Then zip this up and send to the client. The client then:

  1. Unzips the package where ever they like.
  2. Adds the "res" folder under the resources group.
  3. Changes the following target settings:
    Other Linker Flags = -Objc -lfoo
    Header Search Paths = /include
    Library Search Paths = /lib/$(PLATFORM_NAME)

I can probably automate the package creation with some build steps at my end, but the client is stuck with four slightly fiddly steps to get set up.