2

I have a project that uses cocoapods for some time. Recently, I bought an external library from a vendor. This library was sent to me as a static library (.a) and two headers files (.h).

I imported both files and added the static libraries Build Phases -> Link Binary With Librareis. However, my project can not find the static library.

The same library works fine on a project that does not use cocoapods (and workspace). So I think this is a compatibility problem with the configuration made by cocoapods. I've tried to add the static library path to Header Search Path and Library Search Path. No success.

Any suggestions?

hdoria
  • 624
  • 2
  • 14
  • 29

1 Answers1

4

The standard procedure of adding library is

  1. add to OTHER LINKER FLAGS -l${name_of_library_without_LIB_prefix_and_.a_suffix}, for example libz.a will look like -lz
  2. add your library to the library search path. There are useful global vars

$(PROJECT_DIR)

$(SRCROOT)

You can reference it while defining path to your library

  1. add to the HEADER SEARCH PATH path to library headers. You can also use $(PROJECT_DIR) and $(SRCROOT) as a part of the path.

As for using external libraries with CocoaPods - there should be no difference apart from having $(inherited) as a first line of all this settings - library search path, header search path and other linker flags.

Community
  • 1
  • 1
Andrei Shender
  • 2,487
  • 22
  • 15