本文介绍了创建podspec以运送静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过cocoapods发布静态库。我现在没有任何构建方向的图书馆,它是我的iOS应用程序的一个下降。我不需要为每个使用它的应用程序构建库,而只需下载lib文件并包含标题。有没有办法用podspec文件做到这一点?

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

实际的代码结构可以在这里找到: Git Repo

The actual code structure can be found here: Git Repo

推荐答案

当然可以,而且很容易。你的podspec看起来是正确的。

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

我认为你应该创建一个* .framework并将你的库和头文件放在里面,这样就更容易管理了。以下是框架的podspec示例:

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

如果您不想使用* .framework文件,而是使用* .a和* .h文件,这里是一个例子。

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

这篇关于创建podspec以运送静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!