CocoaPods发布框架到远程公有库

  • 1.编写代码~上传远程仓库

    git init
    git add .
    git commit -m '提交到本地分支' //关联远程仓库
    git remote add origin 远程仓库url
    //提交代码到远程仓库
    git push origin master //tag
    git tag //查看版本标签
    git tag -a 1.0.0 -m '1.0.0版本完成' //打完tag 还是处于本地,需要 提交远程代码库
    git push --tags //本地所有tags都提交
  • 2.创建podSpec

        pod spec create 文件名称
    //修改podspec文件内容,如下 假设项目名称Test01
    s.name = "Test01"
    s.version = "1.0.0"
    s.summary = "Test01 is a test lib" s.description = <<-DESC
    "这是一个长的描述字数要比s.summary长,Test01 is a test lib"
    DESC s.homepage = "https://github.com/LouKit/Test01" s.license = "Apache License, Version 2.0"
    s.author = { "LK" => "loukit@qq.com" }
    s.source = { :git => "https://github.com/LouKit/Test01.git", :tag => "#{s.version}" }
    s.source_files = "Classes", "Classes/**/*.{h,m}"
  • 3.podSpec验证

    pod spec lint
  • 4.提交到官方索引库

    //邮箱 密码 填个正确即可,后续需要通过邮箱验证
    pod trunk register loukit@qq.com '随便写' --verbose
  • 5.通过trunk推送podspec文件

    pod trunk push
  • 6.完成

    测试
    pod search Test01
    如果搜索不到,干掉缓存json文件(我电脑路径:/Users/loukit/Library/Caches/CocoaPods/search_index.json)继续搜索即可

CocoaPods本地私有库使用

  • 1.创建本地库
  • 2.创建podSpec文件 //pod spec create 文件名称

    修改podspec文件内容同‘CocoaPods发布框架到远程公有库’,其余:
    # 本地库去掉地址即可
    s.source = { :git => "", :tag => "#{s.version}" }
  • 3.验证

    pod lib lint    
    
    出现⚠警告
    localhost:TestLog LouKit$ pod lib lint -> TestLog (0.0.1)
    - WARN | homepage: The homepage has not been updated from default
    - WARN | url: There was a problem validating the URL http://EXAMPLE/TestLog.
    - WARN | license: Unable to find a license file [!] TestLog did not pass validation, due to 3 warnings (but you can use `--allow-warnings` to ignore them).
    [!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run:
    `echo "2.3" > .swift-version`.
    You can use the `--no-clean` option to inspect any issue.
    警告可接受,无视!
  • 4.创建测试工程,并创建Podfile文件,进行安装本地库

    platform :ios, '9.0'
    
    target 'Example' do
    use_frameworks!
    #描述好本地相对路径
    pod 'Test01',:path => '../Lib/Test01' end
  • 5.安装

    pod install

CocoaPods远程私有库使用

  • 1.创建一个专门用于存放spec文件的远程库

  • 2.将远程库地址加入repo

    pod repo add 名字XX 地址
  • 3.创建本地模板库

    pod lib create spec文件名称  //记得修改podspec文件
  • 4.创建远程库 用于存放 步骤3 存放的库工程

    git add .
    git commit -m 'msg'
    #查看是否有关联远程库,没有需要设置下
    git remote
    //没有设置关联
    git remote add origin 地址
    如:git remote add origin https://git.coding.net/LouKit/xxx.git
    git push origin master
  • 5.验证spec文件

    本地验证 pod lib lint
    远程提交 必须远程验证 pod spec lint (刚刚步骤4提交时没有tag,所以这个步远程验证肯定过不了,需要提交tag) 提交tag:
    git tag 0.1.0
    git push --tags
    //验证
    pod spec lint
  • 6.将spec 推送到步骤1的那个私有库

    pod repo push 名字XX spec文件名称.podspec //这里名字XX 必须对应步骤2 那个名字xx
  • 7.修改宿主工程podfile

    source 'https://git.coding.net/LouKit/xxx.git'
    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '9.0' target 'Example' do
    use_frameworks! pod 'spec文件名称'
    end
  • 8.安装

    pod install

其他

问题 1. 维护阶段(扩充代码,版本号升级)

需重新提交代码 修改spec描述文件,大概步骤如下:

1. 重新提交代码
git add .
git commit -m 'msg'
git push origin master 2. 打tag 同时改spec描述文件
git tag 0.2.0
git push --tags 3. 提交pec文件 4. 更新spec文件到索引库
pod repo push 名字XX spec文件名称.podspec

问题 2. 依赖关系解决(比如制作库需要依赖AFN)

//直接spec文件描述即可
s.dependency 'AFNetworking', '~> 3.1.0'

问题 3. 依赖关系子库解决 
(如一个库里有三个子库,现在只需用到其中一个,不要全部用到 ,即把一个库分成几个小库)

# 代表分离子库
#s.source_files = 'xx/Classes/**/*' 这种写法是匹配所有的 s.subspec 'Category' do |c|
c.source_files = 'xx/Classes/Category/**/*'
end s.subspec 'Network' do |n|
n.source_files = 'xx/Classes/Network/**/*'
n.dependency 'AFNetworking', '~> 3.1.0'
end s.subspec 'Tool' do |t|
t.source_files = 'xx/Classes/Tool/**/*'
end 然后使用这个子库过程podefile 写法
target 'Example' do use_frameworks!
pod 'xx/Category'
pod 'xx/Network'
end

最新文章

  1. python取mysql数据写入excel
  2. Javascript 语言精粹 代码片段合集
  3. DEV中dx:ASPxPopupControl 控件的使用(在窗口关闭或隐藏时,清楚文本框中的内容)
  4. R(八): R分词统计-老九门
  5. 1.4.1.Documents,Fields和Schema概述
  6. Python3.5入门学习记录-File
  7. Qt4----子例化QDialog(可扩展对话框的使用)
  8. 自己动手做聊天机器人 二十九-重磅:近1GB的三千万聊天语料供出
  9. Visual Studio 2015的安装与基本使用
  10. Notification的基本用法以及使用RemoteView实现自定义布局
  11. openfalcon
  12. [USACO09DEC]牛收费路径Cow Toll Paths
  13. hdu 4533 线段树(问题转化+)
  14. bzoj5250 [2018多省省队联测]秘密袭击
  15. Ubuntu更新Python3及pip3
  16. 洛谷 P3373:【模板】线段树 2(区间更新)
  17. 清北冬令营入学测试[ABCDEF]
  18. thrift 安装 make 失败 ar: .libs/ThriftTest_constants.o: No such file or directory
  19. vscode 中使用 csscomb
  20. Throwable、Error、Exception、RuntimeException 区别 联系

热门文章

  1. failure during conversion to COFF:file invalid or corrupt
  2. PHP过狗webshell编写过程
  3. 服务器端实时推送技术之SseEmitter的用法
  4. ROS tf广播编写
  5. 泡泡一分钟:LandmarkBoost: Efficient Visual Context Classifiers for Robust Localization
  6. Django Model 定义语法
  7. 客户端业务层(非数据层json或xml层)的数据结构
  8. npm 安装 -D 和-S的区别
  9. kubectl exec 执行 容器命令
  10. Teaset-React Native UI 组件库