Pods私有库创建步骤

  1. 创建私有 Spec Repo    
  2. 创建Pod项目工程文件
  3. 创建podspec文件
  4. 本地测试podsspec文件
  5. 向Spec Repo提交podspec
  6. Pod库使用
  7. 更新维护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 常用参数:

  1. --sources 编译时需要用到的源码地址。
  2. --use--libraries 编译加载以来的其他静态库。
  3. --allow--warning 编译时允许有警告,如果不设置,出现任何警告都会编译失败。
  4. --verbose 显示编译详细信息。
  5. eg:pod lib lint --sourses=git@10.101.168.28:mobile-ios/xmllibs.git.master --user-libraries --verbose。
  6. pod lib lint 编译的源码来自当前podspec所在目录而不是podspec中source所指定的git的地址。
  7. 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私有库的更多相关文章

  1. 从零开始创建CocoaPods私有库

    为什么要创建CocoaPods私有库? 避免重复的造轮子 节约时间,方便管理自己的代码 精益求精 创建CocoaPods私有库 1.创建私有仓库工程 执行命令pod lib create SmartB ...

  2. iOS 创建本地私有库 保存功能代码

    创建本地私有库 >>> cd /Users/cxx/Desktop/Mange_JJH/Lib >>> pod lib create TZTools >> ...

  3. iOS:最详细的创建CocoaPods私有库教程

    一.感慨 说实话,创建这个CocoaPods私有库,我愣是搞了两个星期,创建的过程中,自己的感情波动是这样的:激情四射---->有点困惑----->极度困惑----->有点失望--- ...

  4. 创建Cocoapods私有库

    本文以自己在公司做的一个手势密码私有库GesturePasswordKit为例说明. 1.在gitlab(或者github,我这里使用的例子是在gitlab上)上创建git仓库 (确保授权正确,避免后 ...

  5. 创建yum私有库

    简述 ​ 在Linux系统中安装软件的方法有三种,分别是rpm软件包安装.yum源安装与源代码编译安装,在用rpm软件包安装软件时会经常出现依赖性问题,导致安装繁琐,用源代码编译安装就更不用说了,相信 ...

  6. iOS组件化开发入门 —— 提交自己的私有库

    前言:本人也是初次接触组件化开发,感觉现有的资料太繁杂,就简单整理了一下,在此跟大家分享一些入手的经验,主要就是描述cocoapods的私有库封装和提交.组件化开发是个大的议题,涉及到架构思路.设计模 ...

  7. 制作CocoaPods公有库和私有库

    认识公有库和私有库 公有库:开源自己封装的库供别人使用,且往cocoaPods的官方Repo仓库(即CocoaPods Master Repo)中新增自己库的索引,该库索引是以*.podspec.js ...

  8. 利用Cocoapods、SVN 创建私有库实现方案(yoowei)

    由于项目年后要进行组件化,考虑到如果公司内部实现一些私有的组件,不对外公开,而又想在不同项目中使用,该怎么办呢? 使用Cocoapods制作私有库就完美的解决了这个问题.下图就是使用私有库带给我们的好 ...

  9. 利用cocoapods创建基于git的私有库

    上一篇文章记录了我利用cocoapods创建基于SVN的私有库的全部过程,今天我再记录一下基于git创建的过程. 整体先说明一下创建一个私有的podspec包括如下那么几个步骤: 创建并设置一个私有的 ...

随机推荐

  1. Qt5+VS2010的安装及使用

    在我的博客<Win7下Qt5的安装及使用>中讲解了win7下Qt5+MinGW的安装及使用,本节再讲解win7下Qt5+VS2010的安装及使用.利用Qt5+MinGW开发应用程序比较麻烦 ...

  2. Xcode 折叠代码快捷键

    Xcode9之前版本可以代码局部和全局折叠,但是9之后只能以某个函数为单位进行全局折叠,特别是里面的逻辑判断的代码不能局部折叠了... Xcode9之前版本代码折叠: 在Xcode菜单里选择Prefe ...

  3. hook 9大类

    HOOK技术主要分为两大类,一是内核层HOOK,一是用户层HOOK. 用户层HOOK也就是在ring3环境下hook kenerl32.dll.User3.dll.Gui32.dll.Advapi.d ...

  4. [转]11种常见sqlmap使用方法详解

    sqlmap也是渗透中常用的一个注入工具,其实在注入工具方面,一个sqlmap就足够用了,只要你用的熟,秒杀各种工具,只是一个便捷性问题,sql注入另一方面就是手工党了,这个就另当别论了.今天把我一直 ...

  5. P3834 【模板】可持久化线段树 1(主席树)

    #include <bits/stdc++.h> #define read read() #define up(i,l,r) for(int i = (l);i <= (r);i++ ...

  6. Java对象的克隆

    今天要介绍一个概念,对象的克隆.本篇有一定难度,请先做好心理准备.看不懂的话可以多看两遍,还是不懂的话,可以在下方留言,我会看情况进行修改和补充. 克隆,自然就是将对象重新复制一份,那为什么要用克隆呢 ...

  7. 微信小程序app.json配置

    找到app.json文件,找到window配置项 1.windows选项下导航栏样式 "navigationBarBackgroundColor":#F6F6F6 // 导航栏的背 ...

  8. nullptr(c++11)

    1.概念 用字面值常量nullptr来初始化或赋值来得到空指针 2.c++11之前使用NULL或0 1)NULL是一个宏定义(预处理变量),定义在cstdlib中,其值就是0:对于预处理变量,预处理器 ...

  9. 写了十年JS却不知道模块化为何物?

    作者:肖光宇 野狗科技联合创始人,先后在猫扑.百度.搜狗任职,爱折腾的前端工程师. 野狗官博:https://blog.wilddog.com/ 野狗官网:https://www.wilddog.co ...

  10. 2014年的最后一个程序,却成为了2015年的第一个bug

    这个点不睡觉的程序员,要么就是在努力学技术,要么就是代码出bug了.而我,是后者.呵呵,2015了,觉还是要睡的