我正在尝试通过cocoapods发布静态库。我的图书馆没有任何构建方向,现在它已经下载到我的iOS应用程序。我不需要为每个使用它的应用程序构建库,而只需下载lib文件并包含头文件。有没有办法用podspec文件做到这一点?
这是我到目前为止所拥有的:
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" => "jon@jumperapp.com" }
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
答案 0 :(得分:3)
当然可以,而且很容易。你的podspec看起来是正确的。
我认为你应该创建一个* .framework并将你的库和头文件放在里面,这样就更容易管理了。以下是框架的podspec示例:
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文件,here's示例。
答案 1 :(得分:1)
我认为你需要像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" => "jon@jumperapp.com" }
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