美文网首页
Git 私有库的创建

Git 私有库的创建

作者: 丨不學無術丨 | 来源:发表于2018-11-08 16:26 被阅读12次

最近在学习组件化。
组件化有一个方案是利用cocoapods进行管理组件。
这就涉及到了specs私有库的创建、维护和使用。


1. 开启显示隐藏文件

为了方便查看某些文件是否完成
//打开隐藏的命令:
defaults write com.apple.finder AppleShowAllFiles -bool true
//关闭隐藏的命令:
defaults write com.apple.finder AppleShowAllFiles -bool false


2. 创建远程组件索引库

该库包含了所有组件的索引以及版本信息。
命名最好以Specs结尾,我采用了coding的免费私有库。


image.png

3. 创建本地组件索引库

终端输入:pod repo add REPO_NAME SOURCE_URL

REPO_NAME:仓库名字,最好和远程索引仓库保持一致,
SOURCE_URL:为仓库地址。
回车后,Finder利用~/.cocoapods/repo查看,可以看到系统已经为我们创建好了文件夹和基本配置。


4. 创建 lib

4.1创建远程代码库

image.png

4.2 本地创建项目,将库文件引入工程, 关联远端的库.

终端输入:pod lib create REPO_NAME

image.png

4.3 将库文件引入工程,

完成后,将你的代码库代替Classes里的ReplaceMe.m

终端进入Example文件夹
pod install
可以看到项目中已经导入添加在Classes里的代码

4.4 将本地 lib 关联到远端库

git add .

git commit -m "first commit"

git remote add origin SOURCE_URL

git tag '0.0.1'

git push --tags

git push -f origin master

5. 配置 podspec 文件

5.1 修改.podspec文件
#
# Be sure to run `pod lib lint basedModule.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             = '组件名字'
  s.version          = '组件版本'
  s.summary          = '组件描述'

# 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
组件详细描述
                       DESC

  s.homepage         = '组件代码主页'
  # s.screenshots     = '组件代码库地址'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { '作者' => '作者地址' }
  s.source           = { :git => '组件代码库地址', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '最低版本'

  s.source_files = '组件名字/Classes/**/*'
  
  # s.resource_bundles = {
  #   '组件名字' => ['组件名字/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end
5.2 检测spec是否可用

pod lib lint --allow-warnings
pod spec lint --allow-warnings

--allow-warnings :忽略所有警告,并通过校验。
--no-clean :检查任何问题。
--verbose :查看详细的验证过程来帮助定位错误
--use-libraries :通过含有.a静态库的验证

5.3 提交 podspec 至私有 Spec 仓库

在 podspec 文件目录执行
pod repo push REPO_NAME MODULE_NAME.podspec --allow-warnings


6.更新 Pod

如果在开发过程中发现某基础组件存在 bug 需要更新 Pod,具体操作步骤如下:

修改 podspec 文件中的 s.version;
修复 bug 并对项目打 tag,tag 名称和 s.version 一直并 push 到远程仓库。
验证 podspec 文件的有效性;
推送 podspec 文件到远程仓库;
执行 pod search RRCache 验证结果;

创建时会遇到的一些问题

  1. 查找有无ERROR,有的话,修复相应的BUG
  2. 没有ERROR,但是有很多WARN,很多WARN无法
    解决的,加上--allow-warnings可以解决
  3. 如果有静态库或者是framework,加上--use-libraries

相关文章

  • ios 私有库创建

    一.创建私有库的索引库 1.git上创建私有索引库 拿到私有库的索引地址(https://github.c...

  • 01 组件开发--远程私有库创建

    远程私有库的创建你也可以使用git,但是git的私有库的创建需要钱,此处我使用"码市" "https://codi...

  • 建立Pod私有库

    source仓库 gitlab上建立MyPodSpecs.git terminal 私有库 创建私有库 提交至服务...

  • iOS CocoaPods私有库

    远程私有库就可以方便的解决以上的问题,制作远程私有库分为以下几个步骤: 创建私有 Git 远程仓库; 创建私有 C...

  • iOS Pod私有库创建步骤

    一:创建pod私有库步骤: 1:先在Git上创建私有库 会得到一个私有仓库地址:htts://github.com...

  • 创建远程私有库

    创建自己的远程私有库过程 创建远程索引库 // git.oschina.net 上创建一个私有项目 ,使用 ssh...

  • cocoaPods私有库创建以及使用,多重库引用

    一、创建本地pod私有库 1.创建git私有库 在进行一切操作之前,先在内网创建一个git仓库。这块我就不多做介绍...

  • iOS-组件化开发- 本地私有库

    1. 创建本地私有库 创建需要做成组件的库1.png 使用git管理git initgit add .git co...

  • iOS--本地私有库和远程私有库(二)

    (二)本地私有库创建及优化 ⅰ.普通版 1.在本地创建库文件 git initgit add .git commi...

  • CocoaPods私有库创建小结

    一、创建私有索引库1.1 在托管平台创建一个项目(有私有权限则创建的是私有索引库,否则则如普通git),如 htt...

网友评论

      本文标题:Git 私有库的创建

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