创建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包括如下那么几个步骤: 创建并设置一个私有的 ...
随机推荐
- java.lang.NoClassDefFoundError: org/apache/ibatis/cursor/Cursor
因为mybatis的版本和mybatis-spring的版本不兼容导致的,解决方法:mybatis的3.4.0及以上版本用mybatis-spring1.3.0及以上版本:mybatis的3.4.0以 ...
- Linux快速安装apache+mysql+php环境
yum -y install httpd mysql mysql-server php php-mysql postgresql postgresql-server php-postgresql ph ...
- IOS初级:SDWebImage
简单用法 #import "ViewController.h" #import "SDWebImage/UIImageView+WebCache.h" @int ...
- myeclipse 上安装 Maven3
myeclipse 上安装 Maven3 环境准备: JDK 1.6 Maven 3.0.4 myeclipse 8.6.1 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Mav ...
- 蛋白序列GO号注释及问题
#=============================== 版本1 ===============================================InterProSc ...
- mysql 5.7 linux环境下解压安装
在CentOS linux环境安装mysql 一般rpm(或者yum),预编译和源码安装. 如果采用rpm或者yum安装,mysql的数据文件一般存放在/var/lib/mysql目录下,也就是会把d ...
- Liferay
Liferay是一个开源公司,我们一般谈Liferay是指的Liferay Portal.Liferay Portal始创于2000年的洛杉机,当时是一个非营利性组织.于2004年建立Liferay公 ...
- JSAAS 平台实现 微信类似的TOKEN机制
在企业微信中,我们在调用微信接口时,我们需要首先获取token,然后根据token,调用API接口方法.这个token是有生命周期的,微信的token默认的生命周期是7200秒. 因此这个token可 ...
- Mybatis之动态构建SQL语句(转)
https://www.cnblogs.com/zhangminghui/p/4903351.html
- ubuntu上安装win7系统(64位的)
http://www.linuxidc.com/Linux/2012-11/74195.htm deb文件在ubuntu上直接用dpkg -i xxx.deb 如果虚拟机上只显示32位,则可能是cpu ...