Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoapods podspec issue

I've been in the process of refactoring some code and have created a static library that I'm now using in a framework that is used in a few apps. I'm using cocoapods and am having trouble properly integrating my new static library into the podspec.

I'm finding that builds are failing because the static library is missing from the build. If I manually add the static library to the final app, the framework and app work fine. A build team generates the final releases of the apps, and because of this I've only been responsible for update the podspec for the framework only.

Is it possible for me to modify the pod spec to set the static library as a linked library that shows up under build phases of the final app?

UPDATE:

When adding the static lib to the framework.library attribute of my sub spec I'm getting library not found for -lMyStaticLib

SUBSPEC FOR REFERENCE:

  s.subspec 'MyStaticLibrary' do |msl|
    mss.source_files = 'FrameworkSource/My-Static-Library/*.{h,a}'
    msl.library = 'MyStaticLib'
    msl.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(SRCROOT)/Pods/My-Framework-Name/FrameworkSource/My-Static-Library"/**', 'LIBRARY_SEARCH_PATHS' => '"$(SRCROOT)/Pods/My-Framework-Name/FrameworkSource/My-Static-Library"/**' }
    #msl.frameworks =  'MyStaticLib'
  end

UPDATE 2: I changed the attribute to msl.vendored_libraries = 'MyStaticLib' Also validated paths in podspec. Everything 'seems' to check out. I'm still getting build errors. When I built for a device (I get same error but for i386 when I build for simulator):

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_MyStaticLibrary", referenced from:
      objc-class-ref in MyFramework(FileInFramework.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I also verified again that if I just go to the app's build phases and traverse the Pods folders and manually add the MyStaticLibrary.a file to the project it builds without issue.

like image 473
propstm Avatar asked Oct 04 '13 19:10

propstm


2 Answers

You can definitely add the framework in your podspec. Check out the wiki entry on the Podspec format.


Edit: Ah, what you're looking for is vendored_frameworks or vendored_libraries which was added in 0.23.0. Looks like those haven't been added to the wiki yet. Will update that now!

like image 60
MishieMoo Avatar answered Sep 18 '22 20:09

MishieMoo


Try renaming your MyStaticLib.a file to libMyStaticLib.a. I was also getting the library not found for -lMyStaticLib error and fixed it by adding a lib prefix to the filename.

like image 29
martin Avatar answered Sep 19 '22 20:09

martin