1、进入git创建仓库
2、终端添加spec repo
pod repo add xxxxKitSpec https://github.com/xxxx/xxxxKitSpec.git
说明:xxxxKitSpec 仓库的repo名
https://github.com/xxxx/xxxxKitSpec.git 是刚创建的远程仓库地址
spec repo 中包含了三方库的podspec 文件,管理pod 库
3、Pod 创建本地工程文件
4、进入刚刚创建的工程目录找到ReplaceMe.swift 文件 替换成自己的库文件
5、测试和验证
1、cd进入目录的Example工程,pod install
2、打开Example工程,进行文件的测试
3、终端输入pod lib lint TestKit.podspec --allow-warnings 进行验证
6、将修改的代码上传到远程仓库
git repo add origin https://github.com/xxx/testkit.git
git push -u origin master
7、打 tag ,这里需要重点注意的是,我们给打的标签值要与podspec文件中的版本号一致。
git tag -m "0.1.1" 0.1.1
git push origin 0.1.1
这里将podspec 推送到本地和远程
8、向私有的spec Repo远程仓库中提交podspec;
使用 pod repo push XXXXSpec XXXX.podspec --allow-warnings
命令把私有库添加到私有repo中。
9、在项目中使用
在工程的podfile文件中添加仓库的地址
source 'https://github.com/xxxx/TestKit.git'
pod "TestKit"
然后 pod install
二、问题记录
问题:error: Command MergeSwiftModule failed with a nonzero exit code
解决方法:project->target->builfsetting->compilation Mode-> debug->切换为whole module
问题:swift语法报错
解决方法:build Settings -> swift language version -> swift 5
问题:建swift版本私有库pod lib lint 报错 The validator used Swift `4.0` by default because no Swift version was specified.
解决方法:在.spec文件里设置swift版本号,根据当前xcode能支持的最高版本来
s.swift_version = '5.0'
问题:不能使用库里面的类和方法
解决方法:需要使用的类、方法、属性 需用 public修饰
问题:报错 No search module
解决方法:在taggets->build phases->Link binary with libraries中删除后再添加
问题:XCode13 Kingfinsger编译报错,这是由于项目中未使用SwiftUI引起
解决方法:
1、在Podfile文件中添加以下代码,将SwiftUI和报错相关代码移除,然后运行pod install即可。
2、添加的代码为platform :ios, "11.0"到use_frameworks!之间
platform :ios, "11.0"
pre_install do |installer|
remove_swiftui()
end
def remove_swiftui
# 解决 xcode13 Release模式下SwiftUI报错问题
system("rm -rf ./Pods/Kingfisher/Sources/SwiftUI")
code_file = "./Pods/Kingfisher/Sources/General/KFOptionsSetter.swift"
code_text = File.read(code_file)
code_text.gsub!(/#if canImport\(SwiftUI\) \&\& canImport\(Combine\)(.|\n)+#endif/,'')
system("rm -rf " + code_file)
aFile = File.new(code_file, 'w+')
aFile.syswrite(code_text)
aFile.close()
end
use_frameworks!
target 'Test' do
pod 'Kingfisher'
end