【iOS】将代码上传到pod创库

2020-03-30 17:10:25 浏览数 (1)

1、利用pod创建项目

代码语言:javascript复制
pod lib create PPKit

这时候的生成工程目录为

目录目录

编写podspec文件

代码语言:javascript复制
#
# Be sure to run `pod lib lint PPKit.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             = 'PPKit'
  s.version          = '0.0.1'
  s.summary          = 'A short description of PPKit.'

# 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/maple1994/PPKit'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'maple1994' => '305554601@qq.com' }
  s.source           = { :git => 'https://github.com/maple1994/PPKit.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '8.0'

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

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

可以看到我们指定source_files指定在PPKit/Classes文件夹下的所有文件,所以我们的源码都放在这里就可以了

2、上传代码到pod

podspec文件编辑好后,我们就可以上传该文件到pod上了,进入podspec同级目

代码语言:javascript复制
pod trunk push

如果之前没有注册pod账号的,先注册/登录也是执行以下指令

代码语言:javascript复制
pod trunk register 305554601@qq.com 'maple'

3、私有库

私有库跟公有库最大的区别就是,podspec的文件摆放位置。如果podspec文件都上传到github上的 https://github.com/CocoaPods/Specs,所以如果我们想搭建私有库,我们也要在自己的仓库搭建一个专门存放specs文件的地方。那么我们上传spec文件的时候,就要添加仓库和推送指定的仓库

代码语言:javascript复制
// 添加
pod repo repoName git@git.xxx.xxx:iOSPods
// 推送
pod repo push repoName xxx.podspec

更详细的内容可以参考 http://www.cocoachina.com/articles/26210

0 人点赞