首页 > 其他分享 >Github制作CocoaPods私有库

Github制作CocoaPods私有库

时间:2022-11-20 18:46:20浏览次数:37  
标签:git 私有 com Github https CDUtils pod CocoaPods

创建私有库模版

使用命令进入到要建立私有库工程的目录,执行以下命令,CDUtils是私有库项目名。

$ pod lib create CDUtils

接下来终端会询问几个问题,请根据实际情况设置:

根据提示最终就会创建一个私有工程。

创建私有库Git地址,这里以Github为例

#
# Be sure to run `pod lib lint CDUtils.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             = 'CDUtils'
  s.version          = '0.0.1'
  s.summary          = 'CDUtils 是一个公共方法库。'

# 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/DavidWanderer/CDUtils.git'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { '[email protected]' => '[email protected]' }
  s.source           = { :git => 'https://github.com/DavidWanderer/CDUtils.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '8.0'

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

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

修改配置文件CDUtils.podspec

安装依赖

命令行进入私有库工程所在目录下的Example文件夹,执行pod install,安装依赖项。

PoetMacBook-Pro:Example kris$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
PoetMacBook-Pro:Example kris$ 

添加库的源代码文件

将源码文件放入CDUtils/Classes目录下,与podspec文件保持一致。

验证私有库的正确性

使用命令验证私有库的正确性。

$ pod lib lint CDUtils.podspec

提交源码到github,并打Tag。

$ git remote add origin https://github.com/DavidWanderer/CDUtils.git

$ git add .

$ git commit -m "0.0.1"

$ git pull origin master

$ git push origin master

$ git tag 0.0.1
 
$ git push origin 0.0.1

创建私有库的索引库

在Github上创建私有库的索引库,并进行初始化操作。

将创建的索引库添加到本地cocoapods仓库

  • 在自己的私有库目录下执行命令,将创建的索引库克隆到本地的cocoapods的仓库中。
    $ pod repo add CDSpecs https://github.com/DavidWanderer/CDSpecs.git
  • cocoapods本地仓库路径为:
    $ ~/.cocoapods/repos

发布私有库

在自己的私有库目录下执行命令,把当前私有库的索引同步到本地索引库,并同步给远程索引库。

$ pod repo push CDUtils CDUtils.podspec

终端截图:

在自己的项目中引用私有库

Podfile如下:

# Uncomment the next line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/DavidWanderer/CDSpecs.git'
platform :ios, '8.0'

target '测试' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!
  pod 'CDUtils', '~> 0.0.1'

end

 

标签:git,私有,com,Github,https,CDUtils,pod,CocoaPods
From: https://www.cnblogs.com/strengthen/p/16909167.html

相关文章

  • Github网站打Tag方法
    热烈欢迎,请直接点击!!!进入博主AppStore主页,下载使用各个作品!!!注:博主将坚持每月上线一个新app!!!登录GitHub,右侧点击【Releases】,输入Tag,比如【1.0.0】,点击【Createnewta......
  • Github添加CocoaPods公开库
    热烈欢迎,请直接点击!!!进入博主AppStore主页,下载使用各个作品!!!注:博主将坚持每月上线一个新app!!!一、上传写好的库到github1.在github上创建一个仓库 2.将仓库拉倒本地......
  • github加速器 FastGithub的安装与使用
    github加速器FastGithub的安装与使用国内访问github网址不稳定,时而可以访问时而访问失败,找到了一个稳定的方法来访问,通过FastGithub加速来进行访问工作原理修改本机......
  • Fiddler收费没得用?这款抓包神器 Github star 过万,一个字:香
    关于抓包,那是测试人员必备技能之一了,通常我们会通过一些抓包工具来辅助我们测试、定位bug。我最早接触并使用的就是fiddler,不过目前最新版本已经要开始付费了,以前很老的......
  • 99:私有方法
    ###私有方法的调用#测试私有属性、私有方法classEmployee:def__init__(self,name,age):self.name=nameself.__age=age#私有实例属......
  • 98:私有属性
    Python对于类的成员没有严格的访问控制限制,这与其他面向对象语言有区别。关于私有属性和私有方法,有如下要点:1.通常我们约定,两个下划线开头的属性是私有的(private)。其他......
  • 云原生之旅 - 13)基于 Github Action 的自动化流水线
    前言GItHubActions是一个持续集成和持续交付的平台,能够让你自动化你的编译、测试和部署流程。GitHub提供Linux、Windows和macOS 虚拟机来运行您的工作流程,或者您可......
  • docker制作镜像、搭建私有仓库registry
    dockerrun-ti --rm--rm运行完自动删除容器是相对隔绝,和物理机共享内核 uname-rdockerinspect  namedocker分层可以节省空间,因为相同层数的镜像内容是只读共享的,......
  • 搭建私有镜像仓库
    目录杭州阿里mkmk仓库启动本地registerserver查看所有仓库修改client端配置测试本地register私有镜像仓库批量推送镜像gpu带数据启动register杭州阿里mkm......
  • python-私有属性和私有方法-笔记
    01.应用场景及定义方式应用场景在实际开发中,对象 的 某些属性或方法 可能只希望 在对象的内部被使用,而 不希望在外部被访问到私有属性 就是 对象 不希望公开的 属......