私有库
创建私有库
创建两个仓库, 一个是私有库容器,一个是代码库
- 私有库:存放若干个代码库的信息
-
添加私有库容器
pod repo add 库名称 地址 -
查看添加的私有库容器
pod repo -
创建代码库,并且clone代码到本地
-
在代码库创建一下文件
代码文件夹,单个仓库名.podspec还有 .swift-version文件 -
修改
.swift-version信息echo "5.0" > .swift-version -
创建podspec文件模板
pod spec create 单个仓库名Pod::Spec.new do |spec| spec.name = "CosClubBasis" spec.version = "0.0.1" spec.summary = "A short description of Basis." spec.homepage = "https://gitee.com/xiquan2019/CosClub_iOS_Basis" spec.license = { :type => "MIT", :file => "LICENSE" } spec.author = { "sharui" => "sr_sharui@qq.com" } spec.source = { :git => "https://gitee.com/xiquan2019/CosClub_iOS_Basis.git", :tag => "#{spec.version}" } spec.requires_arc = true # 是否启用ARC spec.platform = :ios, "10.0" #依赖的文件 spec.dependency "SnapKit", "~> 5.0.0" spec.dependency "RxSwift", "~> 5" spec.dependency "RxCocoa", "~> 5" spec.dependency "Kingfisher", "~> 5.13.3" spec.dependency "Moya", "~> 13.0" # 代码目录 **表示忽略中间文件夹 spec.source_files = "CosClub_Basis/Classes/**/*.{h,m,swift}" end -
验证配置
pod lib lint pod lib lint --allow-warnings #如果出现警告可以用这个忽略警告 # 如果添加依赖文件后 需要在验证的时候添加--sources=地址 因为我这个是清华源 所以加这个地址就可以 pod lib lint 单个仓库名.podspec --allow-warnings --sources=https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git # 如果依赖私有库或者其他源 用','分隔开 --sources="https://gitee.com/xiquan2019/CosClub_iOS_modular.git,https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git" # 验证后出现 单个仓库名 passed validation. -
先提交当前文件, 并打上tag, tag号和上面的版本号保持一致
git tag -a "tagname" -m "说明" # 创建tag git push origin [tagname] 推送tag # 推送tag -
提交到私有库上
pod repo push 仓库名 单个仓库名.podspec --allow-warnings -
在
~/.cocoapods/repos/仓库名中可以查看仓库信息了。 -
如果出现以下信息, 更新版本库既可
pod repo update 仓库名然后再操作第9步就可以了The repo `仓库名` at `../.cocoapods/repos/仓库名` is not clean
验证
pod search 单个仓库名 # 如果成功会出现仓库信息
使用
在Podflie添加Source
source 'https://gitee.com/xiquan2019/CosClub_iOS_modular.git' # 这个地址是私有库容器的地址,不是代码库的地址。
如果Podfile中有原来的source 就保留两个都加上。 加上后的是这样的
# Uncomment the next line to define a global platform for your project
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
source "https://gitee.com/xiquan2019/CosClub_iOS_modular.git"
platform :ios, '10.0'
target 'CosClub' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'SnapKit', '~> 5.0.0'
...
pod 'CosClubBasis','~> 0.0.1' # 私有库
end
pod install # ok
容易出现的问题
.podspec配置中的source_files路径问题