0

I have several projects which share many of the same classes and custom views/view controllers, so I created a custom static library which contain these common classes to be used directly in my client projects.

These are the steps I took:

  1. I created and compiled the static library, copied the resulting .a and public .h files into a folder on my desktop (myLib).

  2. I dragged-and-dropped the myLib folder into my client project. I copied by reference, and did not copy the physical files under my client project. The target's Build Phases "Link Binary With Libraries" phase automatically included the .a file, as expected.

  3. I referenced the View Contollers using the story board for the client project. The classes autocompleted as expected, so Xcode recognizes their existence.

  4. I set the -ObjC and -all_load Linker Flags under my client project build settings and target build settings.

  5. I cleaned and built the client project successfully.

  6. I ran the client project, but the custom view did not load, citing an "Unknown class [myViewController] in Interface Builder file".

Step 6 is the problem I'm facing right now. Here are some other observations that might be useful:

  • In the File Inspector, the headers' target membership is blank; the client project is listed under the Target Membership heading, but the checkbox is disabled and unchecked. The myLib.a target membership is selected, however.

  • I tried to make a subclass of myViewController (clientViewController) in the client project and reference this class instead. When I build the client project, I get an error:

    "warning: directory not found for option '-L/Users/[me]/Desktop/Projects/[clientProject]/[myLib]; Undefined symbols for architecture i386: [clientViewController] in [clientViewController.o]."

Kimi
  • 13,621
  • 9
  • 55
  • 84

1 Answers1

0

Simulator option when you build, looks like you missed. Just use this. this is make a universal framework as easily as making a regular library: iOS-Universal-Framework

Also read a this article: How to create universal static libraries on Xcode 4: the traditional way

bitmapdata.com
  • 9,572
  • 5
  • 35
  • 43
  • I tried building my library using the simulator scheme, but for some reason, my header files didn't copy over when I built the library. I discovered that they would only copy when I chose "iOS Device", so I built under that scheme. Maybe that has something to do with it? Anyway, I will try out this Universal Framework thing, and maybe it will magically solve my problems that I don't really understand. Seems like I need to know a whole lot of nitty-gritty about linkers and processor architectures just to build some shared classes between projects... – user2060086 Feb 11 '13 at 03:38
  • Are you definitely made for Universal? Confusing, read this article: http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/ – bitmapdata.com Feb 11 '13 at 03:40