简体   繁体   中英

How to add a static library to a project that uses cocoapods (iOS)

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM