Use AdobeMobileLibrary (for iOS) with cocoapods?
Asked Answered
E

2

6

We are going to use Omniture-Tracking for iOS, which is part of AdobeMobileLibrary. AdobeAdobeMobileLibrary is not available via cocoapods-repo (only an older version of Omniture), but as a static-library, that you can download from the Adobe Website.

I wonder if it is possible to maintain this static-library with cocoapods?

I've created a podspec-file:

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

In my podfile I reference the podspec-file like s this:

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

In the Pods-project I can see all the files (AdobeMobileLibrary.a, ADBMobile.h, ADBMobileConfig.json)

see https://i.sstatic.net/rnmp1.png

However I cannot build the project and receive this error message:

ld: library not found for -lAdobeMobileLibrary

Does anyone have a clue, what's the problem here?

Is there a different solution to use AdobeMobileLibrary with cocoapods?

Elisa answered 31/3, 2014 at 13:54 Comment(0)
R
4

The issue is due to cocoapods expecting the library to have a lib prefix, i.e. libAdobeMobileLibrary.a in this case. The easiest way to resolve this issue is to create a symbolic link to the library:

ln -s AdobeMobileLibrary.a libAdobeMobileLibrary.a

It's also worth noting that with the Adobe Mobile SDK, the .json file should be included as a resource not as source. Also you'll want to add references to both the SystemConfiguration framework as well as libSqlite3.0.dylib. Here's your pod spec modified accordingly:

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
Rabbit answered 1/4, 2014 at 17:27 Comment(3)
Thanks for this solution! To achieve the issue with the lib-prefix, I've added a Run Script to Build Phases in Xcode, which creates the symbolic link (if not existing).Elisa
AdobeMobileSDK is now also available in cocoapods! cocoadocs.org/docsets/AdobeMobileSDKElisa
"expecting the library to have a lib prefix" Oh my ... thank you !Petrosal
S
4

To be more generic for @fransen's solution, I used prepare_command and preserve_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
Shutout answered 20/5, 2014 at 13:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.