Swift 创建framework上传 cocoaPod

2020-09-07  本文已影响0人  疯狂1024

Swift 创建framework上传 cocoaPod

一、制作framework时注意的问题

写1个Class测试用

open classTestClass:NSObject{

@objc open functest1(){

                 print(#function)

    }

}

在oc调用swift的framework的时候,要引入库的桥接文件xxxx-Swift.h例如:

#import<STestFm/STestFm-Swift.h>

只有方法添加@objc的时候oc才能找到方法。

二、创建仓库

切换到项目目录下,在终端上

pod spec create STestFm

就会生成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    ="远程仓库地址"

spec.license      ="MIT"

spec.ios.deployment_target ='8.0'

spec.author            = {"xxx"=>"xxxxxxxx@qq.com"}

spec.source      = { :git =>"远程仓库地址.git", :tag =>"#{spec.version}"}

spec.source_files  ="Classes","STestFm/*.{swift}"

spec.swift_version ='4.2'

end

swift的framework一定要加spec.swift_version字段。

验证podspec文件是否正确

pod lib lint --allow-warnings

把代码托管在github上,并创建一个0.0.1的tag

git tag 0.0.1

git push origin 1.0.0

三、上传

查看trunk用命令

pod trunk me

如果没有trunk需要注册

pod trunk register 邮箱 名字

如果多人维护,添加其他维护者

pod trunk add-owner 项目名 邮件

上传

pod trunk push STestFm.podspec --allow-warnings

四、私有库

pod repo add 项目名字 仓库地址

pod repo push xxx xxx.podspec --allow-warnings --sources=仓库地址

五、有修改

如果有修改把原先的tag删掉,重新打个tag,在修改下podspec(必须修改)文件,重新pod repo push就好了。

上一篇下一篇

猜你喜欢

热点阅读