创建Pods私有库
Pods私有库创建步骤
- 创建私有 Spec Repo
- 创建Pod项目工程文件
- 创建podspec文件
- 本地测试podsspec文件
- 向Spec Repo提交podspec
- Pod库使用
- 更新维护posspec
名词解释:
repo(repository):私有仓库
spec(specification):pod的描述文件,是描述整个库的远吗的依赖关系和编译规则
repo创建
- 在github/公司的git服务器上创建一个空的git项目。eg:helloRepo
- git clone https://githu.com/xxx/helloRepo
- cd helloRepo/
- pod repo add helloRepo xxx/helloRepo.git 【pod repo add[private repo name][github https clone URL]】
repo 删除
- pod repo remove helloRepo
repo 更新
- pod repo update #默认更新所有repo
- pod repo update hello Repo #更新制定的repo
spec 创建
- pod spec creat <name>
spec 编辑(以AFNetworking为例)
Pod::Spec.new do |s|
s.name = 'AFNetworking'
s.version = '3.2.1'
s.license = 'MIT'
s.summary = 'A delightful iOS and OS X networking framework.'
s.homepage = 'https://github.com/AFNetworking/AFNetworking'
s.social_media_url = 'https://twitter.com/AFNetworking'
s.authors = { 'Mattt Thompson' => 'm@mattt.me' }
s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => s.version, :submodules => true }
#tag指向version,是否有子模块
s.requires_arc = true s.public_header_files = 'AFNetworking/AFNetworking.h' #需要引入的公共头文件
s.source_files = 'AFNetworking/AFNetworking.h' #文件路径 pch_AF = <<-EOS
#ifndef TARGET_OS_IOS
#define TARGET_OS_IOS TARGET_OS_IPHONE
#endif
#ifndef TARGET_OS_WATCH
#define TARGET_OS_WATCH 0
#endif
#ifndef TARGET_OS_TV
#define TARGET_OS_TV 0
#endif
EOS
s.prefix_header_contents = pch_AF #适用版本
s.ios.deployment_target = '7.0'
s.osx.deployment_target = '10.9'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0' s.subspec 'Serialization' do |ss|
ss.source_files = 'AFNetworking/AFURL{Request,Response}Serialization.{h,m}'
#AFURL{Request,Response}Serialization 表示文件名为AFURL开头,包含有Request或Response字符串并以Serialization结尾的文件名。
ss.public_header_files = 'AFNetworking/AFURL{Request,Response}Serialization.h'
#需要应用的系统库
ss.watchos.frameworks = 'MobileCoreServices', 'CoreGraphics'
ss.ios.frameworks = 'MobileCoreServices', 'CoreGraphics'
ss.osx.frameworks = 'CoreServices' #如果要用第三方framework
#ss.vendor_framworks = 'thirdSdk.framwork'
#如果用到第三方.a
#ss.vendor_libraries = 'third.a'
end s.subspec 'Security' do |ss|
ss.source_files = 'AFNetworking/AFSecurityPolicy.{h,m}'
ss.public_header_files = 'AFNetworking/AFSecurityPolicy.h'
ss.frameworks = 'Security'
end s.subspec 'Reachability' do |ss|
ss.ios.deployment_target = '7.0'
ss.osx.deployment_target = '10.9'
ss.tvos.deployment_target = '9.0' ss.source_files = 'AFNetworking/AFNetworkReachabilityManager.{h,m}'
ss.public_header_files = 'AFNetworking/AFNetworkReachabilityManager.h' ss.frameworks = 'SystemConfiguration'
end s.subspec 'NSURLSession' do |ss|
ss.dependency 'AFNetworking/Serialization'
ss.ios.dependency 'AFNetworking/Reachability'
ss.osx.dependency 'AFNetworking/Reachability'
ss.tvos.dependency 'AFNetworking/Reachability'
#需要依赖的子仓库
ss.dependency 'AFNetworking/Security' ss.source_files = 'AFNetworking/AF{URL,HTTP}SessionManager.{h,m}', 'AFNetworking/AFCompatibilityMacros.h'
ss.public_header_files = 'AFNetworking/AF{URL,HTTP}SessionManager.h', 'AFNetworking/AFCompatibilityMacros.h'
end s.subspec 'UIKit' do |ss|
ss.ios.deployment_target = '7.0'
ss.tvos.deployment_target = '9.0'
ss.dependency 'AFNetworking/NSURLSession' ss.public_header_files = 'UIKit+AFNetworking/*.h'
ss.source_files = 'UIKit+AFNetworking'
end
end
spec 编译
- pod lib lint 本地教研pod创建时候正常,执行此命令会根据spec文件配置编译静态库,如果没有报错则表示通过。
pod lib lint && pod spec lint
lint 常用参数:
- --sources 编译时需要用到的源码地址。
- --use--libraries 编译加载以来的其他静态库。
- --allow--warning 编译时允许有警告,如果不设置,出现任何警告都会编译失败。
- --verbose 显示编译详细信息。
- eg:pod lib lint --sourses=git@10.101.168.28:mobile-ios/xmllibs.git.master --user-libraries --verbose。
- pod lib lint 编译的源码来自当前podspec所在目录而不是podspec中source所指定的git的地址。
- pod spec lint 联网校验,通过source中的git地址获取源码,同时还会校验git地址上时候有对应的version字段的tags。
**pod lib lint
will lint your pod locally.and will just ensure that you did provide everything property to create your pod.But it will not be enough to validate your pod.
**pod spec lint
will lint your pod anywhere.it`s mean buy that you can have your pod source code on github for example ant it will lint.if the pod spec lint returns without erros,
you can push the lintedpod spec to cocoa pods.
TD;DR: pod lib lint = local,pod spec lint = local/remote
spec 提交
- 将源码库中的改动(podspec),提交到git
- 新建tag,名字对应podspec中指定的version字段。
- 添加podspec至pod repo
- pod repo push [pod repo xx] xx.podspec
- podspec文件必须lint验证通过后才能提交到spec repo
- 提交前先提交本地源码到对应的git,并创建好对应的tags
pod使用
# Uncomment the next line to define a global platform for your project
platform :ios, '8.0' #如果第一个条件满足就不会去下一个资源地址去搜索
source 'https://github.com/xxx/hello.Repo.git'
source 'https://github.com/CocoaPods/Specs.git target 'HelloSpec' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks! # Pods for HelloSpec
#如果后面跟路径,这忽略上面设置的资源路径
pod 'AFNetworking' #, :path==>'User/xxx/Desktop/cocoapods/AFNetworking' end
创建Pods私有库的更多相关文章
- 从零开始创建CocoaPods私有库
为什么要创建CocoaPods私有库? 避免重复的造轮子 节约时间,方便管理自己的代码 精益求精 创建CocoaPods私有库 1.创建私有仓库工程 执行命令pod lib create SmartB ...
- iOS 创建本地私有库 保存功能代码
创建本地私有库 >>> cd /Users/cxx/Desktop/Mange_JJH/Lib >>> pod lib create TZTools >> ...
- iOS:最详细的创建CocoaPods私有库教程
一.感慨 说实话,创建这个CocoaPods私有库,我愣是搞了两个星期,创建的过程中,自己的感情波动是这样的:激情四射---->有点困惑----->极度困惑----->有点失望--- ...
- 创建Cocoapods私有库
本文以自己在公司做的一个手势密码私有库GesturePasswordKit为例说明. 1.在gitlab(或者github,我这里使用的例子是在gitlab上)上创建git仓库 (确保授权正确,避免后 ...
- 创建yum私有库
简述 在Linux系统中安装软件的方法有三种,分别是rpm软件包安装.yum源安装与源代码编译安装,在用rpm软件包安装软件时会经常出现依赖性问题,导致安装繁琐,用源代码编译安装就更不用说了,相信 ...
- iOS组件化开发入门 —— 提交自己的私有库
前言:本人也是初次接触组件化开发,感觉现有的资料太繁杂,就简单整理了一下,在此跟大家分享一些入手的经验,主要就是描述cocoapods的私有库封装和提交.组件化开发是个大的议题,涉及到架构思路.设计模 ...
- 制作CocoaPods公有库和私有库
认识公有库和私有库 公有库:开源自己封装的库供别人使用,且往cocoaPods的官方Repo仓库(即CocoaPods Master Repo)中新增自己库的索引,该库索引是以*.podspec.js ...
- 利用Cocoapods、SVN 创建私有库实现方案(yoowei)
由于项目年后要进行组件化,考虑到如果公司内部实现一些私有的组件,不对外公开,而又想在不同项目中使用,该怎么办呢? 使用Cocoapods制作私有库就完美的解决了这个问题.下图就是使用私有库带给我们的好 ...
- 利用cocoapods创建基于git的私有库
上一篇文章记录了我利用cocoapods创建基于SVN的私有库的全部过程,今天我再记录一下基于git创建的过程. 整体先说明一下创建一个私有的podspec包括如下那么几个步骤: 创建并设置一个私有的 ...
随机推荐
- invalid END header解决方法
我在Windows上的eclipse开发了一个java web项目,然后压缩成war包,通过ftp发送到Linux服务器上,Tomcat先shutdown,再startup.按理说,会在webapps ...
- PCR技术
qRT-PCR是指先由RNA进行反转录生成cDNA,然后以cDNA为模板进行检测,检测的是该cDNA的含量,而cDNA由特定的RNA逆转录而来,所以间接地检测了RNA的含量. 基因表达: 转录:DNA ...
- Pycharm的常用快捷将
程序运行 Shift+alt+F10 执行程序 debug调试 Shift+alt+F9 Debug调试Shift + F9 对当前文件进行DebugF8 调试模式下 跳过F7 调试模式下 进入F9 ...
- filedisk.sys
i386 amd http://blog.sina.com.cn/s/blog_4fcd1ea30100r19r.html
- MySQL 索引 INDEX
索引用于快速找出在某列中有特定值的行. 不使用索引,MySQL必须从第一条记录开始读完整个表,直到找到相关的行,表越大,查询数据所花费的时间就越多,如果表中查询的列有一个索引,MySQL能够快速到达一 ...
- Vue组件中引入jQuery
一.安装jQuery依赖 在使用jQuery之前,我们首先要通过以下命令来安装jQuery依赖: npm install jquery --save # 如果你更换了淘宝镜像,可以使用cnpm来安装, ...
- Mercurial和Git的主要区别(zz)
Mercurial和Git的主要区别 17 August 2008 1.Mercurial用Python开发,Git用C开发,相对来说,Git比较快,但是Mercurial的性能也不差 2.Mercu ...
- 解决ubuntu常见问题
cd /usr/local/hadoop 1. bash: cd: ~:Permission denied 报错:bash: cd: /usr/local/hadoop:Permission deni ...
- HTML and CSS学习概述
一·Web浏览器是一个连接到Web服务器,向Web服务器请求信息,然后解析返回来的HTML标记,并将其显示在浏览器窗口内的程序.1.Microsoft 2.Internet Explorer(IE)3 ...
- Django之admin管理数据库,cookie验证及分页设置
一.admin管理数据库 1)models.py创建class类表 class Book(models.Model): name=models.CharField(max_length=) price ...