当前位置:网站首页>② cocoapods原理及 PodSpec 文件上传操作
② cocoapods原理及 PodSpec 文件上传操作
2022-06-23 03:48:00 【黑码哥】
cocoapods原理
Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.org/ )源来查找、安装、升级和卸载软件包,非常的便捷。
可以通过 pod --versionn查看pod版本号
可以通过ruby -v查看ruby版本号
可以通过gem -v查看gem版本号
pod基本操作
- 查看第三方框架仓库源
pod repo - 移除仓库源
pod repo remove master - 添加仓库源
pod repo add master http://git.oschina.net/akuandev/Specs.git - 初始化(下载服务器中所有第三方框架信息, 缓存到电脑本地)
pod setup pod search框架关键字—从本地缓存的"第三方框架描述信息" 生成的检索文件中检索到 相关框架的信息- 删除cocoapods索引文件
rm ~/Library/Caches/CocoaPods/search_index.json - 创建 Podfile 文件, 到自己工程内(一级目录)
- Podfile 文件作用?
答: 其实就是使用ruby语法编写的 “框架依赖描述文件”; 就是告诉cocoapods需要下载集成哪些框架 - 创建命令
pod init
- Podfile 文件作用?
- 安装框架
pod install

cocoapods原理图:
sepcs
远程索引库
`pod setup``
其实就是下载远程索引库到本地索引库
如果我们pod install之后,那么下载三方到项目。
当我们另一个项目再次用到这些源码,然后install之后,会很快,因为本地已经备份了一份了
当我们第一次pod search会很慢,因为它再下载下来,然后放到缓存当中,所以下次再执行该操作的话会快好多。下图是缓存路径

创建远程库,并制作PodSpec通过trunk推送podspec文件
第一步,上传项目到github, 并且打好标签
- 具体操作可以看我的第一篇组件化文章git基本使用
git push origin mastergit tag '1.0.0'git push --tags
第二步,注册trunk
pod trunk register 157******[email protected] 'wanggang' --verbose
–verbose参数是为了便于输出注册过程中的调试信息- 注册完以后邮箱会收到邮件,要进去进行校验。
第三步,配置并上传框架的 PodSpec 文件
原理
- PodSpec 文件 描述自己的框架信息:作者,版本, 下载地址等等
- pod search 搜索框架, 就是根据这里面的信息进行检索的
- 注意: 一般这个文件的名称和工程名称保持一致
- 创建命令:
pod spec create 文件名称 - 具体我个人操作:
$ cd /Users/liuxitong/Desktop/testLib
$ pod spec create testLib
这样就创建好了,如图所示:
PodSpec文件格式
- 可以下载被cocoapods管理的框架里面的描述信息, 也可以到官网查看官网链接
- pod spec lint podspec文件
- 如果校验失败,那么就发现哪里有问题就修改podspec对应的地方。
- 某些podspec中的字段解释:
spec.source_files:到地址取得哪些标签文件 通配符表示的是目录,即classes文件夹里的目录
spec.source_files = “Classes”, "Classes//*.{h,m}"
通过trunk推送podspec文件
pod trunk push- 我这里具体操作
pod trunk push testLib.podspec
这样我们就将PodSpec上传成功了,然后我们在cocoapod里面也可以加入我们这个新的第三方库了。 - 这种方式其实就是上传这个描述文件到cocoapods在github上的仓库中,仓库地址
- 然后还需要等待审核,跟pull request一样, 需要作者同意
第四步, 更新本地pod 第三方框架信息数据源
pod setup第五步,使用pod search 命令搜索自己的框架, 如果可以搜索到, 那么代表审核通过了
边栏推荐
- Particle animation background login page particles js
- PTA: spacing of 7-69 data
- 京东云分布式数据库StarDB荣获中国信通院 “稳定性实践先锋”
- Can MySQL be used in Linux
- [Shangshui Shuo series] day three - preview4
- How to make the page number start from the specified page in word
- 无线网络安全的12个优秀实践
- 虫子 STM32 高级定时器 (哈哈我说实话硬件定时器不能体现实力,实际上想把内核定时器发上来的,一想算了,慢慢来吧)
- What is the open source database under Linux
- 华为联机对战服务玩家快速匹配后,不同玩家收到的同一房间内玩家列表不同
猜你喜欢

How MySQL deletes a row of data in a table

在word里,如何让页码从指定页开始编号

Sessions and Daemons

Leetcode 1208. 尽可能使字符串相等(终于解决,晚安)

城链科技董事长肖金伟:践行数据经济系国家战略,引领数字时代新消费发展!

Halcon glue line detection - template matching, pose transformation, glue width, glue continuity detection

Mobile terminal city list sorting JS plug-in vertitylist js

Differences between MyISAM and InnoDB of MySQL storage engine

Xiaojinwei, chairman of Chenglian Technology: implement the national strategy of data economy and lead the development of new consumption in the digital era!

会话和守护进程
随机推荐
移动端城市列表排序js插件vercitylist.js
摆烂LuoGu刷题记
How can I realize video call and interactive live broadcast in a small program?
理想汽车×OceanBase:当造车新势力遇上数据库新势力
PTA: Simulation Implementation of 7-87 set (class template)
Flutter series: wrap in flutter
[advanced binary tree] AVLTree - balanced binary search tree
Halcon glue line detection - template matching, pose transformation, glue width, glue continuity detection
PTA:7-85 数据的间距问题(重载+函数模板)
What is metadata
Zhongang Mining: the demand for fluorite in the new energy and new material industry chain has increased greatly
PTA:7-58 图书音像出租管理
linux下的开源数据库是什么
Online JSON to CSharp (c) class tool
Prince language under insect date category
【二叉树进阶】AVLTree - 平衡二叉搜索树
Background ribbon animation plug-in ribbon js
PTA:6-29 虚基类的应用-人与教师学生
The tax software exits when it detects that it is a virtual machine. How to solve this problem?
Idea import module