iOS开发-创建Cocoapods公有库记录
程序员文章站
2022-03-06 16:10:03
...
1.创建git仓库
2.更新工程代码
通过 git clone https://github.com/haocaihaocai/HCPushSettingViewController.git
将git仓库拉下来,然后将我们的代码添加。
git add .
git commit -m "first commit"
git push
//will enter your account and password
3.生成podspec配置文件
Pod::Spec.new do |s|
s.name = "HCPushSettingViewController"
s.version = "1.0"
s.summary = "A simple push setting viewController,Use for present a new viewController content"
s.description = "A simple push setting viewController,Use for present a new viewController content,HCPushSettingViewController will contain viewController.Support two kinds of content type."
s.homepage = "https://github.com/haocaihaocai"
s.license = "MIT"
s.author = { "sheng" => "aaa@qq.com" }
s.platform = :ios, "8.0"
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/haocaihaocai/HCPushSettingViewController.git", :tag => "#{s.version}" }
s.source_files = "Classes", "Classes/**/*.{h,m,mm}"
s.public_header_files = "Classes/**/*.h"
s.frameworks = "UIKit", "Foundation"
s.requires_arc = true
end
注释解释了很多字段含义,大概就懂了。
4.lint
pod lib lint HCPushSettingViewController.podspec
可以添加--allow-warnings
忽略Warning
gensees-iMac-2:HCPushSettingViewController gensee$ pod lib lint /Volumes/CaiCai/Git/HCPushSettingViewController/HCPushSettingViewController.podspec
-> HCPushSettingViewController (1.0)
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
HCPushSettingViewController passed validation.
HCPushSettingViewController passed validation.
表示成功
5.注册CocoaPods
pod trunk register 277715243@qq.com 'haocaihaocai' --description="create my first CocosPods lib"
会发一份邮件进行确认,确认即可。有账号可以忽略此步
6.检测是否注册成功
gensees-iMac-2:HCPushSettingViewController gensee$ pod trunk me
- Name: HCHC
- Email: 277715243@qq.com
- Since: September 9th, 2019 04:19
- Pods:
- RtSDK
- Sessions:
- September 9th, 2019 04:19 - January 15th, 04:21. IP:
xxxx
- March 16th, 04:23 - July 22nd, 04:26. IP: xxx
Description: create my first CocosPods lib
gensees-iMac-2:HCPushSettingViewController gensee$
7.推送到远程Pod仓库
首先要打个tag
git tag '1.0' //版本和你设置的版本一致
git push ---tags
pod trunk push HCPushSettingViewController.podspec --allow-warnings
//这里如果出现 Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down 则需要更新pod
//更新pod
//查看当前 Cocoapods版本
pod --version
//检查当前 ruby 源,使用 gems.ruby-china.com 源
gem source -l
gem sources --remove 旧源
gem sources -a 新源
//更新Cocoapods
sudo gem install cocoapods 回车然后输入电脑密码
//再次检查当前Cocoapods版本
pod --version
//然后再进行推送
可以从https://cocoapods.org/pods/HCPushSettingViewController
看到你的仓库了。