Create podspec to ship static library
Asked Answered
M

2

13

I'm trying to ship a static library via cocoapods. I was given the library without any build directions right now its a drop in to my iOS app. I don't need to build the library for each application using it, rather just download the lib files and include the headers. Is there a way to do this with a podspec file?

Here's what I have thus far:

Pod::Spec.new do |s|
  s.name         = "RTMPLib Library"
  s.version      = "1.0.0"
  s.summary      = "RTMPLib Library"
  s.homepage     = "https://github.com/jumper/RTMPLib.git"
  s.license      = { :type => 'MIT', :file => 'LICENSE' }
  s.author       = { "jon morehouse" => "[email protected]" }
  s.source       = { :git => "https://github.com/jumper/RTMPLib.git", :tag => "#{s.version}" }
  s.platform     = :ios, '7.0'

  # arc components
  s.requires_arc = false
  s.preserve_paths = 'inc/rtmplib/*.h'
  s.vendored_libraries = 'lib/rtmplib.a'
  s.libraries = 'rtmplib'
  s.xcconfig = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/#{s.name}/inc/rtmplib/**'}
  s.preserve_paths = 'L.framework'
end

The actual code structure can be found here: Git Repo

Marti answered 15/12, 2013 at 7:22 Comment(2)
This seems like a similar problem to: #14103203Dewan
Your Git Repo link is brokenMagus
V
4

Sure it's possible, and it's easy. Your podspec looks correct.

I think you should create a *.framework and put your library and header files inside, so it's easier to manage. Here's an example podspec for a framework:

Pod::Spec.new do |s|
  s.name             = "LibName"
  s.version          = "0.2.0"
  s.summary          = "MySummary"

  s.homepage         = "http://myWebpPage.com/"

  s.license          = 'MIT'
  s.author           = { "Author" => "http://author.com/" }
  s.source           = { :git => "https://github.com/<GITHUB_USERNAME>/Project.git", :tag => s.version.to_s }

  s.platform     = :ios, '7.0'
  s.requires_arc = true
  s.ios.vendored_frameworks = 'StaticLibraryFolder/StaticLibrary.framework'
  s.frameworks = 'CoreData' , 'SystemConfiguration', 'CoreLocation'
  s.weak_framework = 'UIKit'

end

If you don't want to do it with a *.framework file, but with *.a and *.h files instead, here's an example.

Venial answered 22/7, 2015 at 11:43 Comment(3)
I have no idea what you're talking about, it doesn't make sense to me at all. Please read up on "*.framework" extension in the Apple system - it's basically a folder, how can that make anything harder to manage? An advice for the future: when you think someone's wrong, don't condescend and try to insult them by laughing. Maybe try a civil discussion? Especially that it might turn out that you're the one in the wrong. Have a nice day and many, many laughs here on Stackoverflow!Venial
Is using s.ios.vendored_frameworks helps in shipping a static lib via cocopods. Is it possible that this will be treated as a dynamic library?Lui
I create framework contain static lib and header, then pod lib lint spec , it show framework not found error?London
P
2

I think you need do like that demo

 Pod::Spec.new do |s|
 s.name         = "RTMPLib Library"
 s.version      = "1.0.0"
 s.summary      = "RTMPLib Library"
 s.homepage     = "https://github.com/jumper/RTMPLib.git"
 s.license      = { :type => 'MIT', :file => 'LICENSE' }
 s.author       = { "jon morehouse" => "[email protected]" }
 s.source       = { :git => "https://github.com/jumper/RTMPLib.git", :tag => "#{s.version}" }
 s.platform     = :ios, '7.0'

 # arc components
 s.requires_arc = false
# you static library`s .h file
 s.source_files = 'lib/*.h'
 s.vendored_libraries = 'lib/rtmplib.a'

end
Plasticizer answered 26/1, 2016 at 8:27 Comment(1)
The s.vendored_libraries line is what I was missing.Sumatra

© 2022 - 2024 — McMap. All rights reserved.