创建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包括如下那么几个步骤: 创建并设置一个私有的 ...
随机推荐
- spring读取properties的几种方式
参考链接:http://www.cnblogs.com/zxf330301/p/6184139.html
- BZOJ1001或洛谷4001 [BJOI2006]狼抓兔子
BZOJ原题链接 洛谷原题链接 显然就是求最小割. 而对于一个平面图有结论,最大流=最小割=对偶图最短路. 所以这题可用最大流或是转换为对偶图求最短路,这里我是用的对偶图. 虽然理论上按上界算,这题\ ...
- GitHub上README.md教程 详情介绍 (修改图片连接地址错误)
最近对它的README.md文件颇为感兴趣.便写下这贴,帮助更多的还不会编写README文件的同学们. README文件后缀名为md.md是markdown的缩写,markdown是一种编辑博客的语言 ...
- Quartz入门教程
public class App { public static void main(String[] args) throws MessagingException, IOException { / ...
- firefox 之 event兼容写法
event 在 IE 和 FF(Firefox) 中是不兼容的,IE 中可以直接使用 event 对象,而 FF 中则不可以,解决方法之一如下: var event = window.event || ...
- spring jpetstore研究入门(zz)
spring jpetstore研究入门 分类: java2008-12-21 23:25 561人阅读 评论(2) 收藏 举报 springstrutsibatissearchweb框架servle ...
- SpringMVC学习笔记:数据的接收与返回
SpringMVC的定义:Spring Web MVC is the original web framework built on the Servlet API and included in t ...
- 155. Min Stack - Unsolved
https://leetcode.com/problems/min-stack/#/solutions Design a stack that supports push, pop, top, and ...
- unity3DGI
Realtime GI,实时全局光照, 1.构成 : 可实时更新的lightmap + 可实时更新的光照探头(light probe)+ 可实时更新的cubemap(Reflection probe) ...
- Tomcat服务器的安装和配置
一.Tomcat下载 可以直接从Apache的网站上下载Tomcat(http://tomcat.apache.org/),进入首页后,在左边Download一栏可选择你要下载的版本,点击便可进入To ...