在github創(chuàng)建倉庫
打開終端俏橘,依次輸入
cd desktop (要保存的位置)
git clone https://github.com/Zyj163/YJWebViewHolder.git ?(clone后面是剛剛拷貝的地址)
完成之后會(huì)在desktop看到一個(gè)新的文件夾毫炉,將代碼放到這個(gè)文件夾中
cd 當(dāng)前文件夾
pod trunk register 郵箱 '用戶名' --verbose ? ( 注冊(cè)trunk)
pod spec create 項(xiàng)目名 ? (創(chuàng)建一個(gè)以項(xiàng)目名為文件的spec文件)
使用xcode打開這個(gè)文件缠导,編輯內(nèi)容
Pod::Spec.newdo|s|?
s.name='YJWebViewHolder' ? //項(xiàng)目名稱
s.version='1.0.0' ? //版本號(hào)
s.license={:type=>"MIT",:file=>"LICENSE"} ?//license
s.summary='easy use WKWebView in Swift' ?//概述
s.description=<<-DESC ? ? //詳細(xì)描述
easy to use WKWebView in Swift
DESC
s.homepage='https://github.com/Zyj163/YJWebViewHolder' ? //主頁,github上該項(xiàng)目的地址
s.authors={'zhangyj'=>'zyj194250@163.com'} ? //作者
s.source={:git=>'https://github.com/Zyj163/YJWebViewHolder.git',:tag=> s.version } ? ? //項(xiàng)目實(shí)際地址(剛剛clone的地址)胀屿,tag標(biāo)簽塘揣,后面會(huì)添加
s.ios.deployment_target='8.0' ? ?//系統(tǒng)版本
s.source_files='YJWebViewHolder/*.swift' ? ?//實(shí)際框架目錄及文件
// s.verdored_frameworks = "YJWebViewHolder/*.framework" ?//如果打包成.framework
// s.verdored_libraries = "" //如果打包成.a
/*
如果想要把整個(gè)框架分開為幾個(gè)子庫,可供單獨(dú)集成宿崭,source_files要改寫成下面的樣子
s.subspec 'XX' do |x|
x.source_files = 'YJWebViewHolder/XX/*.swift'
x.depedency ?''
x.frameworks ''
end
在Podfile文件可以這樣寫
pod 'YJWebViewHolder/XX'
或者 pod 'YJWebViewHolder', ?:subspaces => ['XX']
*/
s.requires_arc=true ? ?//ARC
s.frameworks="UIKit","WebKit" ? //所包含系統(tǒng)框架
s.depedency ''
s.depedency ''
s.library = "sqlite3"
s.pod_target_xcconfig={'SWIFT_VERSION'=>'3.0'} ? //swift版本
/*
s.source_bundles = {
'YJWebViewHolder' => ['YJWebViewHolder/Assets/*.png'] //資源亲铡,并且在使用的時(shí)候要指定資源的相對(duì)路徑
NSBundle *currentBundle = [NSBundle bundleForClass:];
NSString *imageFile = [currentBundle pathForResource:ofType:inDirectory:];
UIImage *image = [UIImage imageWithContentsOfFile:];
}
*/
/*借助環(huán)境變量的值,來控制加載流程葡兑,使用的時(shí)候奖蔓,安裝命令 ? xx=1 pod install
if ENV["xx"]
else
end
*/
end
pod spec lint YJWebViewHolder.podspec ? ?(驗(yàn)證該文件)
git status (查看文件狀態(tài))
git add . ?(添加所有文件到本地暫緩區(qū))
git commit -m "description" (提交到本地倉庫)
git push ?(提交到遠(yuǎn)程倉庫)
git tag "0.0.1" (添加tag標(biāo)簽)
git push --tags ?(推送所有tag到遠(yuǎn)程倉庫,可以在下圖中位置查看)
pod trunk push (以后提交新版本讹堤,只需要添加對(duì)應(yīng)tag吆鹤,并修改spec文件,然后執(zhí)行該命令即可)
pod setup
使用
在Podfile中添加
pod 'YJWebViewHolder', :git => 'https://github.com/Zyj163/YJWebViewHolder.git'
pod cache clean --all ?清理緩存
使用cocoapods-packager制作靜態(tài)包
安裝:sudo gem install cocoapods-packager
使用:pod package .spec
Carthage的使用及讓自己的項(xiàng)目支持carthage:www.reibang.com/p/bf263c596538
補(bǔ)充一個(gè)在使用的時(shí)候carthage update 失敗洲守,可以嘗試將Cartfile中修改為github "github地址"