Swift 創(chuàng)建framework上傳 cocoaPod
寫1個(gè)Class測試用
open classTestClass:NSObject{
@objc open functest1(){
? ? ? ? ? ? ? ? ?print(#function)
? ? }
}
在oc調(diào)用swift的framework的時(shí)候烹棉,要引入庫的橋接文件xxxx-Swift.h例如:
#import<STestFm/STestFm-Swift.h>
只有方法添加@objc的時(shí)候oc才能找到方法拇舀。
切換到項(xiàng)目目錄下,在終端上
pod spec create STestFm
就會(huì)生成STestFm.podspec文件运褪。
編輯STestFm.podspec文件宾袜。
Pod::Spec.newdo|spec|
spec.name? ? ? ? ="STestFm"
spec.version? ? ? ="0.0.1"
spec.summary? ? ? ="STestFm的概要說明"
? spec.description? = <<-DESC
STestFm的描述
? ? ? ? ? ? ? ? ? DESC
spec.homepage? ? ="遠(yuǎn)程倉庫地址"
spec.license? ? ? ="MIT"
spec.ios.deployment_target ='8.0'
spec.author? ? ? ? ? ? = {"xxx"=>"xxxxxxxx@qq.com"}
spec.source? ? ? = { :git =>"遠(yuǎn)程倉庫地址.git", :tag =>"#{spec.version}"}
spec.source_files? ="Classes","STestFm/*.{swift}"
spec.swift_version ='4.2'
end
swift的framework一定要加spec.swift_version字段。
驗(yàn)證podspec文件是否正確
pod lib lint --allow-warnings
把代碼托管在github上貌嫡,并創(chuàng)建一個(gè)0.0.1的tag
git tag 0.0.1
git push origin 1.0.0
查看trunk用命令
pod trunk me
如果沒有trunk需要注冊
pod trunk register 郵箱 名字
如果多人維護(hù)该溯,添加其他維護(hù)者
pod trunk add-owner 項(xiàng)目名 郵件
上傳
pod trunk push STestFm.podspec --allow-warnings
pod repo add 項(xiàng)目名字 倉庫地址
pod repo push xxx xxx.podspec --allow-warnings --sources=倉庫地址
如果有修改把原先的tag刪掉朗伶,重新打個(gè)tag,在修改下podspec(必須修改)文件步咪,重新pod repo push就好了论皆。