CocoaPods私有仓库创建记录

一、创建版本库

以码云为例子:

WechatIMG1.jpeg

然后再终端

pod repo add XHRepo  https://gitee.com/woshidrq/XHRepo.git

前往如下目录:

~/.cocoapods/repos/master
WechatIMG2.jpeg

如上图就是XHRepo 就是增加的仓库

二、创建pod项目

pod lib create XHKit

执行之后会在终端出现


bogon:Desktop rrd$ pod lib create XHKit
Cloning `https://github.com/CocoaPods/pod-template.git` into `XHKit`.
Configuring XHKit template.
/Users/rrd/Desktop/XHKit/setup/TemplateConfigurator.rb:207: warning: Insecure world writable dir /Users/rrd/Library in PATH, mode 040707

------------------------------

To get you started we need to ask a few questions, this should only take a minute.

If this is your first time we recommend running through with the guide: 
 - https://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and double click links to open in a browser. )


What platform do you want to use?? [ iOS / macOS ]
 > iOS

What language do you want to use?? [ Swift / ObjC ]
 > ObjC

Would you like to include a demo application with your library? [ Yes / No ]
 > Yes

Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > None

Would you like to do view based testing? [ Yes / No ]
 > Yes

What is your class prefix?
 > XH

Running pod install on your new library.

按需选择即可

填完选项之后会创建一个项目XHkit, 在XHKit文件夹里有俩个文件夹,
Assets 存储图片等资源
Classes 存放代码

WechatIMG3.jpeg

进入XHKit项目 修改 spec文件

#
# Be sure to run `pod lib lint XHKit.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             = 'XHKit'
  s.version          = '0.1.0'
  s.summary          = 'A short description of XHKit.'

# 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://gitee.com/woshidrq/XHKit'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'xh' => '[email protected]' }
//自己地址
  s.source           = { :git => 'https://gitee.com/woshidrq/XHKit.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/'

  s.ios.deployment_target = '8.0'

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

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

执行

  pod lib lint --allow-warnings --verbose

无报错继续

git remote add origin https://gitee.com/woshidrq/XHKit.git//这里是你需要pod的项目地址,不是私有仓库的地址
git add .
git commit -m "init"
git push origin master

为仓库打tag

git tag -m "0.1.0"  0.1.0
git push --tags

最后,将你的spec push到 XHRepo(我的私有仓库),

pod repo push XHRepo XHKit.podspec --allow-warnings 

以上推送远程仓库,打tag可以借助git工具sourcetree来进行。

三、测试私有pod

在podfile中写

source 'https://gitee.com/woshidrq/XHRepo.git'
platform :ios, ‘8.0’ 

target ‘XHKitDemo’ do

pod 'XHKit'

end

然后pod install即可

四、新功能继续pod发布

把新代码直接放到Classes

修改.podspec   1.0.0

push 代码到仓库

打tag 1.0.0

push tag

pod repo push XHRepo XHKit.podspec --allow-warnings 

重新 pod update 

五、这样的代码没有按照物理文件夹进行分类

WechatIMG5.jpeg

解决办法:

#
# Be sure to run `pod lib lint XHKit.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             = 'XHKit'
  s.version          = '1.0.0'
  s.summary          = 'A short description of XHKit.'

# 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://gitee.com/woshidrq/XHKit'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'xh' => '[email protected]' }
  s.source           = { :git => 'https://gitee.com/woshidrq/XHKit.git', :tag => s.version.to_s }
  
  #分类文件夹1
  s.subspec 'Category' do |ss|
    ss.source_files = 'XHKit/Classes/Category/**/*'
   
    end
    
    #分类文件夹2
    s.subspec 'currentVC' do |ss|
      ss.source_files = 'XHKit/Classes/currentVC/**/*'
     
      end
  s.ios.deployment_target = '8.0'
  # s.source_files = 'XHKit/Classes/**/*'
  s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end

你可能感兴趣的:(CocoaPods私有仓库创建记录)