Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create podspec to ship static library

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

like image 601
JonMorehouse Avatar asked Dec 15 '13 07:12

JonMorehouse


People also ask

What is Podspec?

A Podspec, or Spec, describes a version of a Pod library. One Pod, over the course of time, will have many Specs. It includes details about where the source should be fetched from, what files to use, the build settings to apply, and other general metadata such as its name, version, and description.

Are CocoaPods static or dynamic?

CocoaPods pod-linkage plugin. In SwiftKey, we have a dynamic framework that we use to share code between the app and the keyboard extension, and all the pods are linked statically except for some of them that are linked dynamically because they are linked to the app and keyboard extension too.


1 Answers

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.

like image 96
michal.ciurus Avatar answered Oct 03 '22 17:10

michal.ciurus