+7  A: 

Try dragging the static library into your xib browser in Interface Builder. I haven't tried this with a static library, but the concept is the same. When you drag header files into IB, you can access those classes.

Reed Olsen
Dragging the header files directly into the XIBs browser/explorer worked - dragging the static library did not.
teabot
A: 

Can someone please clarify what the "XIB browser/explorer" is? Also, where were the header files dragged in from, exactly? (The static lib project itself, or somewhere else?)

See original question - it's been updated.
teabot
Thanks!After dragging in my header file from my static lib project, and doing a clean build, at runtime I still get "Unknown class MyComponent in Interface Builder file" when the view is shown. No idea what I'm missing.
I assume that the static lib project has been included in your project that contains the XIB file?
teabot
Yup! My actual objective C code can instantiate objects that come from my static lib code at runtime jkust fine. It's just that the interface builder stuff can't see the classes at runtime.If I try moving the UIView subclass in question out of the static lib and into the project which uses the static lib, everything works. Btw, I've set up my projects - my static lib and the project that uses it - by following this tutorial:http://www.clintharris.net/2009/iphone-app-shared-libraries/Maybe there's some crucial thing this tutorial misses out? I'll have a look.Thanks!
Ok, here's something interesting. If I add a call in my main project to a class method in MyComponent in the static lib, a class method that does nothing, it all works.So from what I can see, when I compile my main project, the compiler is dropping MyComponent from the static lib at link time, because it can't see MyComponent being used in any code in my main project. I'm guessing the interface builder nob instantiation stuff uses reflection to instantiate the MyComponent class.There must be a better way to fix this than the above hack though!
A: 

I have the same problem as you, teabot. I created a static library which includes UIViews. But when I create a UIView with Interface Builder and I want to associate it with one of my views defined in my static library, I couldn't: my Inspector doesn't know my own classes.

Currently, I can only use my static library with XCode.

Is it possible to use static library with IB? If yes, how?

Thanks for your help.

Max Brice
I have a solution for your problem teabot. In IB, select File > "Read Class Files..." and then select the headers of the classes of your static library you want have access from IB.I just tried, and it's working for me now.
Max Brice
A: 

LexH, try linking with the -ObjC flag when building your static library. That worked for me... for about a year :-) I found this post as the problem has returned with a fresh OSX install and an upgrade in xcode. But it worked in XCode 3.1.2.

  • David
Dave
A: 

Add the same problem as LexH. It worked only when I called a dummy class method. The problem was that I did not add my static library to the "link binary with libraries" under target. Strangely everything else worked.

I followed this guide to link with my static lib Create static lib

CodeFlakes
A: 

I had the same problem. Dragging the library or headers to XIB Browser didn't work. Read Class Files didn't work. So I called:

[MyLibraryClass version];    // Substitute your class name for "MyLibraryClass".

This worked. version is a class method of NSObject, so all subclasses of NSObject inherit it.

Michael Hourigan
A: 

Michael where did you type [MyLibraryClass version]; ???

Marco