制作Swift 私有库 上传 Pod

最近工作需要做framework,遇到一些问题做下记录。

用swift语言创建framework,在创建2个target(swift,oc)做测试用。如下图

一、制作framework时注意的问题

写1个Class测试用

open class TestClass: NSObject {
    
    @objc open func test1(){
        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.new do |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             = { "yhl" => "753597827@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字段。

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

验证podspec文件是否正确

pod lib lint --allow-warnings

验证通过

 

三、上传

查看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就好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值