当前位置:网站首页>② 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 命令搜索自己的框架, 如果可以搜索到, 那么代表审核通过了
边栏推荐
- [从零开始学习FPGA编程-40]:进阶篇 - 设计-竞争与风险Risk或冒险
- 顺序表查找
- PTA:7-86 集合的模拟实现(函数模板)
- JD cloud distributed database stardb won the "stability practice pioneer" of China Academy of information technology
- How to ensure application security
- Adobe international certification 𞓜 how IIT Madras brings efficiency and accessibility to scholars through Adobe e Acrobat
- 仿360桌面悬浮球插件
- Basic skills of x64dbg
- Ideal car × Oceanbase: when new forces of car building meet new forces of database
- Introduction to deep learning
猜你喜欢

Mobile terminal city list sorting JS plug-in vertitylist js

Flutter series: wrap in flutter

IDEA-导入模块

Particle animation background login page particles js

无线网络安全的12个优秀实践

svg d3.js生成tree树状图

Create a desktop shortcut to your appimage

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

背景彩带动画插件ribbon.js

Deploying Apache pulsar on kubesphere
随机推荐
Inscription of lougu brush
How to make the page number start from the specified page in word
Review the SQL row column conversion, and the performance has been improved
虫子 日期类 上 太子语言
How to process large volume xlsx/csv/txt files?
2022年的软件开发:首席信息官应该知道的五个现实
Mysql, field problem
Xiaojinwei, chairman of Chenglian Technology: implement the national strategy of data economy and lead the development of new consumption in the digital era!
PTA:7-64 该日是该年的第几天
Online JSON to CSharp (c) class tool
flutter系列之:flutter中的Wrap
在word里,如何让页码从指定页开始编号
怎么用好MySQL索引
linux下的开源数据库是什么
Imitation 360 desktop suspended ball plug-in
京东云分布式数据库StarDB荣获中国信通院 “稳定性实践先锋”
Introduction to deep learning
What is metadata
Getting started with tensorflow
Svg+js smart home monitoring grid layout