CocoaPods私有仓库

整体先说明一下创建一个私有的podspec包括如下那么几个步骤(有些不一定要要按顺序来):

  1. 创建一个存放私有仓库podspec文件的git仓库
  2. 在本地CocoaPods创建一个Spec Repo管理本地仓库
  3. 创建Pod工程,并关联到其中一个git仓库
  4. 创建Pod所对应的podspec文件。
  5. 本地验证podspec文件是否可用。
  6. 向私有的Spec Repo中提交podspec
  7. 在个人项目中的Podfile中添加存放podspec的git路径
  8. 在终端pod install 就可以了
  9. 后期更新维护podspec

创建本地Spec Repo管理仓库PDGGSpecs是你本地的仓库名 https://github.com/PanDongGG/DemoSpecs.git 是存放私有仓库podspec文件的git仓库

pod repo add PDGGSpecs https://github.com/PanDongGG/DemoSpecs.git

创建Pod工程,并关联到其中一个git仓库

修改pod工程的podspec文件

Pod::Spec.new do |s|

#项目名称
  s.name             = 'PodDemo'

#项目版本号
  s.version          = '0.1.0'

#描述
  s.summary          = '私有仓库demo'

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

#个人信息首页

  s.homepage         = 'https://blog.csdn.net/dreamJuvenile'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'

#许可证类型,以及文件
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'antihumanPerson' => '[email protected]' }

#注意是本项目仓库地址,而非存放podspec仓库地址   版本号
  s.source           = { :git => 'https://github.com/PanDongGG/PodDemo.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

#兼容到某版本号

  s.ios.deployment_target = '8.0'

#代码文件路径

  s.source_files = 'PodDemo/Classes/**/*'
  #资源文件路径
  # s.resource_bundles = {
  #   'PodDemo' => ['PodDemo/Assets/*.png']
  # }

#依赖哪些库

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

验证podspec文件是否规范可用

pod lib lint PodDemo.podspec

如果验证不通过可以通过--verbose 命令看详细报错信息

pod lib lint PodDemo.podspec --verbose

如果只是经过可以通过命令--allow-warnings直接忽略

pod lib lint PodDemo.podspec --allow-warnings

验证通过后关联并提交到git仓库

git add .
git commit -m "提交说明"
git remote add origin https://github.com/PanDongGG/PodDemo.git
git push -u origin master

在这里注意打上标签也就是版本号与你的podspec文件的s.version一致就好

git tag 0.1.0

git push --tags origin master

然后就可以推到到Spec Repo了

pod repo push PDGGSpecs PodDemo.podspec

在别的项目使用这个私有仓库

在podfile文件添加

source 'http://github.com/PanDongGG/DemoSpecs.git'
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
target 'Demo' do

       pod 'PodDemo'

end

然后在终端pod install就可以了

如果更新私有库的代码想要提交上去

修改podspec文件的s.version的版本

#项目版本号
  s.version          = '0.1.1'

然后更新代码到git仓库

git add .

git commit -m "提交说明"

git remote add origin https://github.com/PanDongGG/PodDemo.git git push origin master

git tag 0.1.1

git push --tags origin master

最后再次Spec Repo了

pod repo push PDGGSpecs PodDemo.podspec

猜你喜欢

转载自blog.csdn.net/dreamJuvenile/article/details/81480263