四步走:
一、封装自己的轮子
创建自己的工程,编写代码。
pod lib create 工程名称
给自己的项目打上tag
git tag -a 0.0.1 -m 'release 0.0.1'
git push origin --tags
//查看tag
git tag
//删除一个指定的tag,并上传一个空tag到远程tag
git tag -d
二、注册trunk
pod trunk register 你的邮箱 '你的名字'
有一封邮件会发到你的邮箱 点击链接验证一下即可。
pod trunk me 验证是否注册成功
三、发布到cocoapods
1.进入项目创建.podspec文件
pod spec create xxxx 生成xxxxx.podspec
2.编辑xxxxx.podspec文件
Pod::Spec.new do |s|
s.name = "项目名称"
s.version = "0.0.1" #项目版本号
s.summary = "A short description of HXCommonUnit."
s.description = <<-DESC
通用工具
DESC
s.homepage = "https://github.com/duhongxing/HXCommonUnit.git"
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
s.license = "MIT"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
s.author = { "Author" => "邮箱" }
# Or just: s.author = "Author"
# s.authors = { "Author" => "邮箱" }
# s.social_media_url = "http://twitter.com/Author"
# s.platform = :ios
s.platform = :ios, "8.0"
# When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"
s.source = { :git => "https://github.com/Author/HXCommonUnit.git", :tag => "0.0.1" }
s.source_files = "HXCommonUnit/HXCommonUnit/Classes/*.{h,m}"
#s.exclude_files = "Classes/Exclude"
# s.public_header_files = "Classes/**/*.h" 公开的头文件
# s.resource = "icon.png"
# s.resources = "Resources/*.png"
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
s.framework = "UIKit" 用到的framework系统库
# s.frameworks = "SomeFramework", "AnotherFramework" //依赖多个系统库
# s.library = "iconv"
# s.libraries = "iconv", "xml2"
s.requires_arc = true 是否支持ARC
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# s.dependency "JSONKit", "~> 1.4" 依赖的三方库
end
3.验证
pod spec lint HXCommonUnit.podspec --allow-warnings
4.发布
pod trunk push HXCommonUnit.podspec --allow-warnings
5.等待发布成功
四、搜索一下,验证是否成功
[!] Unable to find a pod with name, author, summary, or descriptionmatching `HXCommonUnit`
本地搜索索引清除一下吧:
rm ~/Library/Caches/CocoaPods/search_index.json
重新搜索:
pod search HXCommonUnit
等待中....