2013-11-26 70 views
0

我想建立一個我沒有開發的第三方庫的podspec。包括靜態庫沒有-l

我已經正確定義:source,preserve_paths,resources和source_files。

這個庫包含一個靜態庫(.a文件)。我試圖使用vendored_library和庫。我也嘗試使用xconfig設置'LIBRARY_SEARCH_PATHS'。我沒有辦法讓它工作。

我從編譯日誌,如果我手動包括圖書館將其與以下PARAMS編譯註意到:

".. -framework CoreMedia /Users/luca/..path to the lib.../thelib.a -framework ..." 

和它的作品。如果我使用的吊艙這將是(根據規格)或者是

".. -framework CoreMedia -l/Users/luca/..path to the lib.../thelib.a -framework ..." 

".. -framework CoreMedia -lthelib.a -framework ..." 

我硬是花了4小時試圖解決這個問題。任何人都可以幫忙嗎?

回答

2

這些是需要和爲我工作完美的線。 s.ios.vendored_library是你缺少的。

s.preserve_paths = 'libCocoaLib.a'

s.library = 'CocoaLib'

s.ios.vendored_library = 'libCocoaLib.a'

s.ios .vendored_library將在您的Pod中創建一個Frameworks文件夾,其中包含lib

0

在可可豆莢的情況下,我已經成功地做到這一點是這樣的:

s.preserve_paths = 'libYandexMobileMetrica.a'

s.libraries = 'YandexMobileMetrica'

一般來說,要將庫包含到項目中,您需要向連接器添加標誌,告訴它與庫(從man ld)鏈接:

選項控制庫

-lx   This option tells the linker to search for libx.dylib or 
      libx.a in the library search path. If string x is of the 
      form y.o, then that file is searched for in the same places, 
      but without prepending `lib' or appending `.a' or `.dylib' to 
      the filename. 

然後你需要路徑到庫再次從連接手動添加到庫搜索路徑爲連接器,:

-Ldir 
      Add dir to the list of directories in which to search for 
      libraries. Directories specified with -L are searched in the 
      order they appear on the command line and before the default 
      search path. In Xcode4 and later, there can be a space 
      between the -L and directory.