Github代码上传Cocoapods

此文章演示Demo:https://github.com/ColdChains/MenuBarController.git

一、本地处理
1.新建工程,并创建Framework和Demo 两个Target
在这里插入图片描述

2.在.h文件里import所有需要外部访问的文件
在这里插入图片描述

3.修改需要外部访问的.h文件权限:选中.h文件在右侧的Target Membership勾选Framework Target并将权限改为Public
在这里插入图片描述
a.修改.m文件的Target Membership勾选Demo Target
在这里插入图片描述
b.也可以通过配置Build Phases引入Framework,但是需要每次改动后切换到Framework Target编译一下重新生成Framework文件
在这里插入图片描述

3.在Demo Target里引用文件测试
在这里插入图片描述
4.创建LICENSE文件

MIT License

Copyright (c) <时间2022> <作者ColdChains>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5.创建podspec文件

pod spec create <工程名MenuBarController>

6.修改podspec文件


Pod::Spec.new do |spec|

  spec.name         = "MenuBarController"
  # 版本号,每次更新需要修改
  spec.version      = "0.0.2"
  # 简介
  spec.summary      = "Controller with menu bar that can slide and handles UIScrollView Nested"
  # 详细介绍
  spec.description  = <<-DESC
Controller with menu bar that can slide and handles UIScrollView Nested.
                   DESC

  spec.homepage     = "https://github.com/ColdChains/MenuBarController"

  spec.license      = { :type => "MIT", :file => "LICENSE" }

  spec.author             = { "ColdChains" => "coldchains@qq.com" }

  spec.platform     = :ios, "9.0"

  spec.source       = { :git => "https://github.com/ColdChains/MenuBarController.git", :tag => "#{spec.version}" }

  # 需要打包的文件路径
  spec.source_files  = "MenuBarController/**/*.{h,m}"
  # 需要过滤的文件路径
  spec.exclude_files = "Classes/Exclude"
  # swift项目需要指定版本号
  # spec.swift_version = "5.6"
  
  # spec.public_header_files = "Classes/**/*.h"

  # 需要依赖的三方库
  spec.dependency "Masonry"

end

7.验证podspec

 pod lib lint
// 如果有warn可以使用--allow-warnings忽略
pod lib lint --allow-warnings

有Error根据提示修改,如果出现MenuBarController.podspec passed validation.表示成功
在这里插入图片描述

二、GitHub处理
1.在github上创建仓库,将本地工程及LICENSE、podspec文件都上传到远程仓库

2.打tag

// 创建tag
git tag <tag名0.0.1>
// 推送到远程
git push --tags

如果重新提交代码可以将tag删除重新打

//删除本地tag
git tag -d  <tag名0.0.1>
//删除远程tag
git push origin :<tag名0.0.1>

3.创建realease版本
在这里插入图片描述
三、CocoaPods处理
1.注册CocoaPods账号

pod trunk register <邮箱地址> <用户名>
// 带描述信息
pod trunk register <邮箱地址> <用户名> —description=<描述信息>

执行命令后会受到邮件,打开邮件中的链接成功注册

2.检查是否创建成功

pod trunk me

在这里插入图片描述

3.验证podspec

pod spec lint
// 如果有warn可以使用--allow-warnings忽略
pod spec lint --allow-warnings

在这里插入图片描述
此过程和上传时可能遇到网络问题慢或者卡住,出现MenuBarController.podspec passed validation.表示验证成功

4.上传库

// 更新
pod repo update
// pod repo update --verbose

// 上传
pod trunk push <MenuBarController>.podspec
// 如果有warn可以使用--allow-warnings忽略
pod trunk push <MenuBarController>.podspec --allow-warnings

在这里插入图片描述
5.查询上传的库

// 删除本地索引文件
rm ~/Library/Caches/CocoaPods/search_index.json
// 更新本地库
pod repo update
// 或
pod repo update --verbose
// 搜索上传的库
pod search MenuBarController

在这里插入图片描述

在线查询地址 https://cocoapods.org

四、删除已上传的库

pod trunk delete <库名> 0.0.1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值