一. 创建GitHub 仓库
登录GitHub 账号后台 点击加好 点击New repository
创建代码仓库 填写仓库名称 填写描述 选择Public 公有仓库,选择初始化README,选择 add a license 选择Mit
如何忘记添加license 可以创建后添加,请参考 https://stackoverflow.com/questions/31639059/how-to-add-license-to-an-existing-github-project
创建成功
二. 上传代码
点击右上角Clone or download 再点击Open in Desktop
安装Github Desktop 客户端后 点击允许。这时候选择个地方存放文件夹路径
然后把代码copy 到 你下载的文件夹里
填写提交代码的信息、
然后点击Commit to master 在点击有上角同步
然后点击项目目录到GitHub 仓库去,发现代码已同步到代码仓库
上传成功
三. 创建cocoapods 账号
查看是否注册cocoapods账号
pod trunk me
[!] You need to register a session first. 提示没有注册
pod trunk --help
+ add-owner Add an owner to a pod
+ delete Deletes a version of a pod.
+ deprecate Deprecates a pod.
+ info Returns information about a Pod.
+ me Display information about your sessions
+ push Publish a podspec
+ register Manage sessions
+ remove-owner Remove an owner from a pod
pod trunk register --help
$ pod trunk register EMAIL [NAME]
Register a new account, or create a new session.
If this is your first registration, both an EMAIL
address and your
NAME
are required. If you’ve already registered with trunk, you may omit
the NAME
(unless you would like to change it).
It is recommended that you provide a description of the session, so that
it will be easier to identify later on. For instance, when you would like
to clean-up your sessions. A common example is to specify the location
where the machine, that you are using the session for, is physically
located.
Examples:
$ pod trunk register eloy@example.com 'Eloy Durán' --description='Personal Laptop'
$ pod trunk register eloy@example.com --description='Work Laptop'
$ pod trunk register eloy@example.com</code></pre>
Options:
--description=DESCRIPTION An arbitrary description to easily identify your
session later on.
--silent Show nothing
--verbose Show more debugging information
--no-ansi Show output without ANSI codes
--help Show help banner of specified command
pod trunk register lengshengren@gmail.com 'lengshengren' --description='Work Laptop'
[!] Please verify the session by clicking the link in the verification email that has been sent to lengshengren@gmail.com
接下来就登录邮箱点击链接确认下就可以了
ACE, YOU’RE SET UP.
创建 podspec 文件
pod spec create AKToast
Specification created at AKToast.podspec
这时候本地工程有个AKToast.podspec,打开该文件,修改相关配置
Pod::Spec.new do |s|
s.name = "AKToast"//组件库名称
s.version = "0.0.1"//版本号
s.summary = "A short description of AKToast."//概要
s.description = "hud"//描述
s.homepage = "https://github.com/lengqingfeng/AKToast"//代码主页
s.license = "MIT"//开源协议
s.platform = :ios
s.platform = :ios, "8.0"//最低版本号
s.source = { :git => "https://github.com/lengqingfeng/AKToast.git", :tag => s.version }//源地址
s.source_files = "AKToast/AKToastClass/**/*.{h,m}"//代码路径
s.requires_arc = true //是否Arc
s.dependency "MBProgressHUD", "~> 1.0.0"//依赖的库
end
然后远程链接看是否报错
pod lib lint --verbose AKToast.podspec
如何报错就必须解决才能下一步 我遇到一个比较棘手的问题
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information. - NOTE | xcodebuild: /Users/lengshengren/Documents/AKToast/AKToast/ViewController.m:10:9: fatal error: 'AKToast.h' file not found
AKToast.podspec passed validation.
后台发现是文件里路径错误:AKToast.podspec(source_files
) 开始一直认为编译那地方出错了
如何有警告可以忽略掉
pod lib lint - -allow-warnings
链接成功后创建tag
$ git add -A && git commit -m "Release 0.0.1."
$ git tag '0.0.1'
$ git push --tags
让后推送代码到cocoapods 仓库。
pod trunk pushAKToast.podspec
Pro-2:AKToast lengshengren$ pod trunk me
- Name: lengshengren
- Email: lengshengren@gmail.com
- Since: August 9th, 06:28
- Pods:
- AKToast
- Sessions:
- August 9th, 06:28 - December 16th, 04:49. IP: 106.11.34.17 Description: Work Laptop
pod search AKToast 可能会报错
[!] Unable to find a pod with name, author, summary, or description matching AKToast
解决方法
r -rf ~/Library/Caches/CocoaPods
pod setup