2013-12-15 106 views
8

我試圖通過cocoapods發佈一個靜態庫。我現在被授予了沒有任何構建方向的圖書館,直接進入我的iOS應用程序。我不需要爲使用它的每個應用程序構建庫,而只需下載lib文件幷包含頭文件。有沒有辦法用podspec文件做到這一點?創建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" => "[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

+0

這似乎是一個類似的問題: http://stackoverflow.com/questions/14102703/cocoapod-podspec-and-framework – Wilmar

+0

您的Git Repo鏈接已損壞 –

回答

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文件來做到這一點,但* u和* .h文件代替,here's一個例子。

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" => "[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