美文网首页
1.iOS搭建公司自己的私有库

1.iOS搭建公司自己的私有库

作者: ProfessorFan | 来源:发表于2024-09-09 18:21 被阅读0次

问题

1.iOS 私有库存在的意义
2.整么搭建一个iOS私有库呢

答案

1.iOS 私有库存在的意义

当我们到达一家新的工作单位之后,特别是公司没有iOS项目基础的时候,为了公司项目有技术积累,作为一个有信仰的iOS开发人员就需要搭建公司的 私有库了。搭建私有库的好处就不用我多说了。

2.整么搭建一个iOS私有库呢

2.1 最终结果显示

 Tip: cocoapod 整么安装,这里就不做详细解释了,作为一个iOS开发人员,这个是最基础的工具,我就当你掌握这些基本知识了

假设我们开发了一个私有库 LAAlamofire 最终结果应该如下图1.1.png,LASpec 是我们的索引库,LAAlamofire 使我们自己开发的库


1.1.png

2.2 创建流程

  • 1.创建自己的索引库 LASpec
在任意目录下执行如下命令:
pod repo add LASpec https://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@github.com/MMSuperD/LASpec.git

索引库的名字: LASpec
索引库的地址: https://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@github.com/MMSuperD/LASpec.git

如果出现如下错误 :fatal: unable to access 'https://github.com/MMSuperD/LASpec.git/': Error in the HTTP2 framing layer
解决方案: 多尝试几次,换个网络尝试

成功后的结果是:在 ~/.cocoapods/repos目录下面新增了 一个 LASpec 文件夹
  • 2.创建自己的代码仓库LAAlamofire
在桌面创建自己的代码文件夹:cd 到自己的文件夹目录执行如下代码:
pod lib create LAAlamofire
代码库的名字: LAAlamofire
如果出现 错误: fatal: unable to access 'https://github.com/CocoaPods/pod-template.git/': Error in the HTTP2 framing layer
同样的方式切换网络,多尝试几次
过长中:
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 ]
 > Yes

到这里基本上我们的本地 pod LAAlamofire,基本已经创建完毕了

  • 3.修改自己的本地代码库LAAlamofire
    LAAlamofire.podspec 文件
    核心点(具体什么意思自行查阅):

s.version = '0.1.1'
s.source = { :git => 'https://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@github.com/MMSuperD/LAAlamofire.git', :tag => s.version.to_s }
s.ios.deployment_target = '15.0'

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

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

  s.ios.deployment_target = '15.0'

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

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
    s.dependency 'Alamofire', '~> 5.6.4'
end
  • 4.把我们本地LAAlamofire的代码推到远端仓库
首先 pod install 
git add .
git commit -m "init"
git remote add origin https://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@github.com/MMSuperD/LAAlamofire.git
git push origin main -f  (这里第一次强制推送到 远端如果你不强制推送到远端,那你就一步一步拉 之后在推 git pull origin main --allow-unrelated-histories --no-rebase,建议强制推送)

自己打tag: git tag 0.1.1
推送tag:git push origin --tags
  • 5.本地库,远程库校验
本地库校验
pod lib lint LAAlamofire.podspec --verbose --allow-warnings
远端库校验
pod spec lint --verbose --allow-warnings
  • 6.推送本地库在索引库中更新
pod repo push LASpec LAAlamofire.podspec --allow-warnings

参考文献

私有库文献

相关文章

  • iOS组件化之搭建私有库(Gitlab+Cocoapods)

    搭建私有库(PrivateSpec) 前言:多项目多工程组件化之路,之前搭建了公司内部私有库,有空整理了下资料 1...

  • iOS开发私有库的创建

    近期由于自己在玩玩私有库和公有库,记录下来自己搭建的过程。私有库可以本地和远程,这里主要是将远程库的搭建。 当然在...

  • Android-私有库搭建

    Android私有库搭建网上已经有很多教程了,这里是根据网上的文章结合自己搭建流程做下记录。 私有库搭建目的 每个...

  • maven备忘

    1. 搭建私有库 使用docker搭建私有maven库,docker image为sonatype/nexus3 ...

  • 私有npm库搭建 & Vue npm组件发布

    一、私有库搭建 本文私有库在linux中使用docker搭建 拉最新镜像docker pull verdaccio...

  • 用cocoapods搭建私有库遇到的问题

    最近要将公司项目中几个自有库用pod统一管理,分别熟悉了一下在svn和git上搭建私有库的过程。这里记录下搭建私有...

  • pod 私有库搭建流程

    Pod私有库是什么: 搭建步骤 1.创建远程索引私有库 2.创建远程私有库 3.在本地添加一个自己的远程索引库 4...

  • iOS创建cocoapods私有索引库

    1.创建私有索引库 1.1.在码云或github(自己公司搭建的git也行)上创建一个私有索引仓库,例如"JJBR...

  • 组件化(二):远程私有库的升级+依赖+私有库分支

    组件化学习之路文章集合: 组件化(一):搭建远程私有库 上一篇文章我们介绍了如何搭建自己的远程私有库,本篇我们就继...

  • 搭建自己的私有库

    搭建属于自己的私有库的文章已经很多了,我这给大家推荐几个链接,大家可以先试着做,如果过程中遇到问题,我尽力和大家共...

网友评论

      本文标题:1.iOS搭建公司自己的私有库

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