1、创建一个文件夹Self-iOS
cd /Users/.../Documents/Self-iOS
2、创建一个仓库模板
pod lib create CJGViewKit
控制台打印如图:
过程中会选择内容,根据提示输入回车就可以
What platform do you want to use?? [ iOS / macOS ]选择开发平台
What language do you want to use?? [ Swift / ObjC ]选择开发语音
Would you like to include a demo application with your library? [ Yes / No ] 选择是否自动生成demo
Which testing frameworks will you use? [ Specta / Kiwi / None ]选择是否创建模拟测试库文件
Would you like to do view based testing? [ Yes / No ]选择是否展示测试
What is your class prefix?选择私有库名称的前缀
创建模板成功后的文件目录
Example 是例子demo;
CJGViewKit 下是仓库资源,代码文件放在Classes中,图片资源在Assets中
3、设置CJGViewKit.podspec并校验格式
主要设置
s.name 库名
s.version 版本
s.summary 简介
s.description描述
如果填写不正确 校验的时候会报错
校验:
pod lib lint CJGViewKit.podspec --allow-warnings
CJGViewKit passed validation.成功!
4、将代码、文件资源等放入相应目录
git add .
git commit -m "INIT CJGVIEWKIT"
git remote add origin [https://gitee.com/saesar_chen/cjgnavigation-controller.git](https://gitee.com/saesar_chen/cjgnavigation-controller.git)
===========================================
至此私有库创建完成,下面在此基础上将私有库发布到cocoapods
5、给仓库添加tag,并发布到cocoapods
git tag -a 1.0.0
git push origin master
pod trunk push CJGViewKit.podspec --allow-warnings
这样开源库制作完成!
pod search CJGViewKit
如果搜索不到运行
rm ~/Library/Caches/CocoaPods/search_index.json
pod repo update --verbose
问题1:ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
pod lib lint CJGMediaFramework.podspec --allow-warnings --verbose --use-libraries --skip-import-validationd
pod trunk push CJGMediaFramework.podspec --allow-warnings --verbose --skip-import-validation --use-libraries --skip-import-validation