美文网首页
CocoaPods远程Pod库和本地Pod库

CocoaPods远程Pod库和本地Pod库

作者: 迷路的小小 | 来源:发表于2019-11-26 16:40 被阅读0次

pod lib create

通过执行pod lib create ComponentFW0(pod lib create ComponentFW0 --template-url=https://github.com/CocoaPods/pod-template.git)时,下载一个pod模板,然后更改.podspec文件的配置定制化自己的pod。

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

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

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

Which testing frameworks will you use? [ Quick / None ]
 > none

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

podspec

Pod::Spec.new do |s|
  s.name             = 'ComponentFW0'
  s.version          = '0.1.0'
  s.swift_version    = '4.0'
  # 当我们对库文件内容进行更新时, 需要同时更改s.version值
  # 注意:每次更新,版本号只能往上增,不能降
  s.summary          = 'A short description of ComponentFW0.'

# 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/jbxb/ComponentFW0.git'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'jbxb' => '2062964913@qq.com' }
  s.source           = { :git => 'https://gitee.com/jbxb/ComponentFW0.git/ComponentFW0.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
  s.ios.deployment_target = '8.0'
  s.requires_arc = true
  s.source_files = 'ComponentFW0/Classes/**/*'
 
  # s.resource_bundles = {
  #   'ComponentFW0' => ['ComponentFW0/Assets/*.png']
  # }

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

验证.podspec文件的合法性

这里需要终端cd到HomeComponent.podspec文件所在文件夹,执行:
pod lib lint HomeComponent.podspec --verbose

- NOTE  | [iOS] xcodebuild:  xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Pod库(远程)

创建本地索引库,并与远程索引库关联
pod repo add <本地索引库名称> <远程索引库地址.git>
查看是否创建成功
pod repo

➜  ComponentFW0 git:(master) ✗ pod repo add ComponentFW0 https://gitee.com/jbxb/ComponentFW0.git
Cloning spec repo `ComponentFW0` from `https://gitee.com/jbxb/ComponentFW0.git`
Username for 'https://gitee.com': jbxb
Password for 'https://jbxb@gitee.com': 
➜  ComponentFW0 git:(master) ✗ pod repo
ComponentFW0
- Type: git (master)
- URL:  https://gitee.com/jbxb/ComponentFW0.git
- Path: /Users/**/.cocoapods/repos/ComponentFW0

master
- Type: git (master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/**/.cocoapods/repos/master

trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/**/.cocoapods/repos/trunk

3 repos

使用

远程公有私有Git库
pod 'ComponentFW0', :git => 'https://gitee.com/jbxb/ComponentFW0.git'
本地pod库
pod 'ComponentFW0', :path => './ComponentFW0'

相关文章

网友评论

      本文标题:CocoaPods远程Pod库和本地Pod库

      本文链接:https://www.haomeiwen.com/subject/vgjdwctx.html