CocoaPods创建私有库和私有库更新

一、创建私有库步骤

1.查看本地仓库(防止命名冲突)

pod repo

2.添加远程repo索引库

pod repo add pod https://github.com/nia-bit/TEST2.git

pod repo add [私有库名] [远程仓库地址]

添加完成之后pod repo一下来检验添加是否成功

3.添加需要的项目文件并上传到远程私有库

cd pod:进入到对应的项目文件夹

cd pod
pod lib create test

test:私有仓库名

创建成功后会自动打开项目文件,下面这个图片全是自动执行的奥

索引文件,这个都是自动生成的,你只需要改版本号

s.version = '0.1.0'这里

扫描二维码关注公众号,回复: 17640048 查看本文章
#
# Be sure to run `pod lib lint test.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'test'
  s.version          = '0.1.0'
  s.summary          = 'A short description of test.'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://github.com/nia-bit/test'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'nia-bit' => '邮件地址(自动生成的)' }
  s.source           = { :git => 'https://github.com/nia-bit/test.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '10.0'

  s.source_files = 'test/Classes/**/*'
  
  # s.resource_bundles = {
  #   'test' => ['test/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end

将本地pod库上传到远程私有库

修改完.podspec文件之后,使用质量检测工具检测下当前的项目是否没有问题,成功了会显示test passed validation

pod lib lint --allow-warnings --use-libraries

4、关联远程仓库提交

git add .git
git commit -m "提交"
git remote add origin https://github.com/nia-bit/TEST2.git
git push https://github.com/nia-bit/TEST2.git main

指定tag

git tag '0.1.0'
 git push –-tags

检查spec文件

最后关联远程仓库

pod repo push pod test.podspec --allow-warnings

二、更新已有的仓库

其实创建的步骤更新依旧适用,只需要在本地修改需要修改的文件,然后检测代码和索引文件没问题之后打tag推送然后和远程索引库关联就好啦,使用的时候只需要在podfile文件指定版本号就行了