3

I have created a static library following this link.

But I am facing Problems in using the library. For reference on how to use static libraries in an iPhone project I followed this link .

But I am stil struggling with the "How to implement static libraries in any other iPhone project?" question.

Thank you all.

Quinn Taylor
  • 44,553
  • 16
  • 113
  • 131
SocialCircus
  • 2,110
  • 6
  • 24
  • 35

1 Answers1

5

You can use cross-project referencing as in the posts but this has several downturns.

I use this setup that works on Xcode in general (not only for the iPhone) and adds compile-time static library version control.

I put my static libraries in ~/Library/MyLibraries/, the .a archive along with their public headers. This way you can have different versions of them:

~/Library/MyLibraries/
                     /MyLib-1.0.0/Headers/header1.h
                                         /header2.h
                                 /libmylib.a
                                 /libmylib_debug.a
                     /MyOtherLib-2.1.0/Headers/...
                                      /libmyotherlib.a

Then in Xcode settings add the user variables:

LIBRARIES_DIR      $(USER_LIBRARY_DIR)/MyLibraries
MYLIBRARY_LIBROOT  $(LIBRARIES_DIR)/MyLib-1.0.0

and modify the settings

HEADER_SEARCH_PATHS $(MYLIBRARY_LIBROOT)/Headers
OTHER_LDFLAGS       $(MYLIBRARY_LIBROOT)/libmylib.a

Now change MYLIBRARY_LIBROOT to choose your library version. More on this blog post by me.

If you want to keep it simple then just compile the library and setup HEADER_SEARCH_PATHS and OTHER_LDFLAGS.

IlDan
  • 6,851
  • 3
  • 33
  • 34
  • The drawback (which might be a benefit, depending on your needs) of this approach is that the static library will not automatically re-compile when you compile the projects that use them. – Felixyz Jul 14 '09 at 12:47
  • Certainly. But you want to develop and debug and test your library separately, that's the point of having a real library. You'll go out of sync soon anyway... ;) – IlDan Jul 14 '09 at 13:15