美文网首页iOS
组件化之pod 私有库

组件化之pod 私有库

作者: 天之朗 | 来源:发表于2022-09-02 17:55 被阅读0次
基本步骤:

>1.添加远程私有索引库(specs)
>2.创建私有库
>3.把私有库的spec 添加到私有索引库

>4.podfile添加
// 第一行添加
  source 'https://github.com/china/WTYSpecs.git'
  source 'https://github.com/CocoaPods/Specs.git'
//pod "私有库" // 可公有库一样

一.创建私有Specs

1.创建私有Specs

 pod repo add [Private Repo Name] [GitHub HTTPS clone URL]
$ pod repo add WTYSpecs https://github.com/china/WTYSpecs.git

比如如何删除私有仓库:pod repo remove [name]。

二.创建私有库:

1.创建私有库
创建私有库命令
2.修改podSpec文件
#
# Be sure to run `pod lib lint WTYLogin.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 http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'WTYLogin'
  s.version          = '0.1.0'
  s.summary          = ' WTYLogin 是登录模块'

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

  s.ios.deployment_target = '8.0'

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

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

3.创建远程仓库
a. 创建远程仓库
4添加远程仓库
$ git remote add origin git@github.com:china/WTYLogin.git
$ git push -u origin master
$ git tag 0.1.0
$ git push origin --tags
5.验证是否通过

TIPS:
pod lib lint是只从本地验证你的pod能否通过验证
pod spec lint是从本地和远程验证你的pod能否通过验证
我一般都是直接使用pod spec lint去验证pod有没有问题
pod spec lint --allow-warnings 忽略警告

deMacBook-Pro:WTYLogin $ pod spec lint

 -> WTYLogin (0.1.0)

Analyzed 1 podspec.

WTYLogin.podspec passed validation.

deMacBook-Pro:WTYLogin $ 

三.添加索引

$ cd 到.pospec 所在目录
$ pod repo push WTYSpecs WTYLogin.podspec 

四.调用

// 第一行添加
  source 'https://github.com/china/WTYSpecs.git'
  source 'https://github.com/CocoaPods/Specs.git'
//pod "私有库" // 和公有库一样

常见问题

1.私有库引用私有库的问题
在私有库引用了私有库的情况下,在验证和推送私有库的情况下都要加上所有的资源地址,不然pod会默认从官方repo查询。

pod spec lint --sources='私有仓库repo地址,https://github.com/CocoaPods/Specs'
如:
pod repo push 本地repo名 podspec名 --sources='私有仓库repo地址,https://github.com/CocoaPods/Specs'


相关文章

  • 私有CocoaPods库使用一

    目的 私有pod库引用私有pod库或静态库 使用场景 项目组件化, 工具组件化很好实现, 但是业务组件化就没那么容...

  • iOS组件化探究之私有库的创建

    iOS组件化探究之私有库的创建 iOS组件化探究之私有库的创建

  • 组件化之pod 私有库

    一.创建私有Specs 1.创建私有Specs 比如如何删除私有仓库:pod repo remove [name]...

  • HCMediator组件化详解

    组件化创建流程库 组件化需要创建私有spec库(索引库)、HCMediator库(App中介库)、其他组件库 私有...

  • 组件学习

    创建私有库 命令:pod lib create HNTest 注意:此处HNTest为你的组件名称 私有库创建完成...

  • iOS 组件化之抽取私有Pod库

    引言 最近对组件化相关的知识比较感兴趣,翻看了好多大神的博客,算是对组件化有个大概的了解了。所谓的组件化,一方面是...

  • 组件化方案之创建Pod私有库

    最近公司的项目因为功能较多,复杂度较高,所以打算使用组件化方案去解耦业务,当然组件化方案的考虑有很多,不过这里我们...

  • 最新iOS组件化之pod私有库

    远程索引库: 存在一个公共的远程索引库,包含所有三方框架的.podspec文件,在.podspecs文件中包括了框...

  • 组件化开发(四)本地私有库

    通过本地私有库实现组件化开发 组件化开发分为本地私有库和远程私有库,这里我们先来学习如何通过本地私有库实现组件化的...

  • 私有源创建组件库方法

    私有源page 组件库整体概念:如果只是一个单独的pod 库 下载需要这样引入 pod '库名字':git=>'...

网友评论

    本文标题:组件化之pod 私有库

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