2014-03-31 76 views
4

我們將使用Omniture-Tracking for iOS,它是AdobeMobileLibrary的一部分。 Adob​​eAdobeMobileLibrary不可通過cocoapods-repo(僅適用於舊版本的Omniture)提供,但作爲靜態庫,您可以從Adobe網站下載。使用cocoapods使用AdobeMobileLibrary(用於iOS)?

我不知道是否有可能用cocoapods維護這個靜態庫?

我已經創建了一個podspec文件:

Pod::Spec.new do |s| 
    s.name   = 'AdobeMobileLibrary' 
    s.version  = '4.0.2' 
    s.license  = 'Commercial' 
    s.summary  = 'Adobe Omniture SiteCatalyst analytics library for iOS.' 
    s.homepage  = 'https://developer.omniture.com/en_US/content_page/mobile/c-measuring-mobile-applications' 
    s.author   = { 'Adobe Omniture SiteCatalyst' => 'http://www.adobe.com/solutions/digital-marketing.html' } 
    s.source_files = 'AdobeMobileLibrary/*.{json,h}' 
    s.ios.vendored_library = 'AdobeMobileLibrary/AdobeMobileLibrary.a' 
    s.library  = 'AdobeMobileLibrary' 
    s.xcconfig  = { 'LIBRARY_SEARCH_PATHS' => '"$(PODS_ROOT)/AdobeMobileLibrary"' } 
end 

在我podfile我引用podspec文件,比如s這樣的:

pod 'AdobeMobileLibrary', :path => 'AdobeMobileLibrary.podspec' 

在莢項目我可以看到所有的文件(AdobeMobileLibrary.a,ADBMobile.h,ADBMobileConfig.json)

看到 http://i.stack.imgur.com/rnmp1.png

但是我不能生成項目,並收到此錯誤信息:

ld: library not found for -lAdobeMobileLibrary 

有沒有人有一個線索,這裏有什麼問題嗎?

是否有與cocoapods一起使用AdobeMobileLibrary的不同解決方案?

回答

3

問題是由於的CocoaPods希望圖書館有LIB前綴,即libAdobeMobileLibrary.a在這種情況下。解決這個問題最簡單的方法是創建一個符號鏈接庫:

ln -s AdobeMobileLibrary.a libAdobeMobileLibrary.a 

這也是值得注意的是,與Adobe移動SDK,在以.json文件應作爲一種資源而不是源。你也想添加對SystemConfiguration框架以及libSqlite3.0.dylib的引用。這裏是你的莢規範相應的修改:

Pod::Spec.new do |s| 
    s.name   = 'AdobeMobileLibrary' 
    s.version  = '4.0.2' 
    s.license  = 'Commercial' 
    s.summary  = 'Adobe Omniture SiteCatalyst analytics library for iOS.' 
    s.homepage  = 'https://developer.omniture.com/en_US/content_page/mobile/c-measuring- mobile-applications' 
    s.author   = { 'Adobe Omniture SiteCatalyst' => 'http://www.adobe.com/solutions/digital-marketing.html' } 
    s.source_files = 'AdobeMobileLibrary/*.h' 
    s.resource  = 'AdobeMobileLibrary/ADBMobileConfig.json' 
    s.framework  = 'SystemConfiguration' 
    s.ios.vendored_library = 'AdobeMobileLibrary/AdobeMobileLibrary.a' 
    s.libraries  = 'sqlite3.0','AdobeMobileLibrary' 
    s.xcconfig  = { 'LIBRARY_SEARCH_PATHS' => '"$(PODS_ROOT)/AdobeMobileLibrary"' } 
end 
+0

感謝這個解決方案! 爲了解決lib-prefix的問題,我在Xcode中添加了一個運行腳本來構建階段,這會創建符號鏈接(如果不存在)。 – awBSH

+0

Adob​​eMobileSDK現在也可以** cocoapods **! http://cocoadocs.org/docsets/AdobeMobileSDK/ – awBSH

+0

「期待庫有一個lib前綴」哦,我的......謝謝你! –

2

成爲@ fransen的解決方案更通用,我用prepare_commandpreserve_paths

Pod::Spec.new do |s| 
    s.name   = 'AdobeMobileLibrary' 
    s.version  = '4.0.2' 
    s.license  = 'Commercial' 
    s.summary  = 'Adobe Omniture SiteCatalyst analytics library for iOS.' 
    s.homepage  = 'https://developer.omniture.com/en_US/content_page/mobile/c-measuring- mobile-applications' 
    s.author   = { 'Adobe Omniture SiteCatalyst' => 'http://www.adobe.com/solutions/digital-marketing.html' } 
    s.source_files = 'AdobeMobileLibrary/*.h' 
    s.resource  = 'AdobeMobileLibrary/ADBMobileConfig.json' 
    s.framework  = 'SystemConfiguration' 
    s.preserve_paths = 'AdobeMobileLibrary/libAdobeMobileLibrary.a' 
    s.ios.vendored_library = 'AdobeMobileLibrary/AdobeMobileLibrary.a' 
    s.prepare_command = <<-CMD 
      if [ -f $PWD/AdobeMobileLibrary/libAdobeMobileLibrary.a ] 
      then 
       rm -rf $PWD/AdobeMobileLibrary/libAdobeMobileLibrary.a 
      fi 
      ln -s $PWD/AdobeMobileLibrary/AdobeMobileLibrary.a $PWD/AdobeMobileLibrary/libAdobeMobileLibrary.a 
          CMD 
    s.libraries  = 'sqlite3.0' 
    s.xcconfig  = { 'LIBRARY_SEARCH_PATHS' => '"$(PODS_ROOT)/AdobeMobileLibrary"' } 
end