[iOS]使用CocoaPods发布私有库

1.创建私有 Spec 仓库

首先,需要一个私有的 Git 仓库来存放你的 Podspec 文件,这个仓库用于索引你所有的私有 Pods。

  • 在 GitHub 或其他 Git 服务上创建一个新的私有仓库,例如,名为 PrivatePodSpecs
  • 克隆这个仓库到本地:
$ git clone https://github.com/yourusername/PrivatePodSpecs.git

 

 

2.准备你的组件库

确保你的库的代码已经在一个可访问的 Git 仓库中(比如 GitHub 的私有仓库)。库中应该包含:

  • 所有源代码
  • 许可证文件
  • README 文件,说明库的功能和使用方法

3.创建 Podspec 文件

在你的库项目的根目录下,执行以下命令来创建一个基本的 Podspec 文件:

$ pod spec create YourLibrary

这将创建一个名为 YourLibrary.podspec 的文件,其中 YourLibrary 是你的库的名字。CocoaPods 会自动填充一些基本的模板内容到这个文件中。

#
#  Be sure to run `pod spec lint MyComponent.podspec' to ensure this is a
#  valid spec and to remove all comments including this before submitting the spec.
#
#  To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html
#  To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |spec|

  # ―――  Spec Metadata  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  These will help people to find your library, and whilst it
  #  can feel like a chore to fill in it's definitely to your advantage. The
  #  summary should be tweet-length, and the description more in depth.
  #

  spec.name         = "MyComponent"
  spec.version      = "0.0.1"
  spec.summary      = "A short description of MyComponent."

  # 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!
  spec.description  = <<-DESC
                   DESC

  spec.homepage     = "http://EXAMPLE/MyComponent"
  # spec.screenshots  = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"


  # ―――  Spec License  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Licensing your code is important. See https://choosealicense.com for more info.
  #  CocoaPods will detect a license file if there is a named LICENSE*
  #  Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
  #

  spec.license      = "MIT (example)"
  # spec.license      = { :type => "MIT", :file => "FILE_LICENSE" }


  # ――― Author Metadata  ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Specify the authors of the library, with email addresses. Email addresses
  #  of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
  #  accepts just a name if you'd rather not provide an email address.
  #
  #  Specify a social_media_url where others can refer to, for example a twitter
  #  profile URL.
  #

  spec.author             = { "" => "" }
  # Or just: spec.author    = ""
  # spec.authors            = { "" => "" }
  # spec.social_media_url   = "https://twitter.com/"

  # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  If this Pod runs only on iOS or OS X, then specify the platform and
  #  the deployment target. You can optionally include the target after the platform.
  #

  # spec.platform     = :ios
  # spec.platform     = :ios, "5.0"

  #  When using multiple platforms
  # spec.ios.deployment_target = "5.0"
  # spec.osx.deployment_target = "10.7"
  # spec.watchos.deployment_target = "2.0"
  # spec.tvos.deployment_target = "9.0"
  # spec.visionos.deployment_target = "1.0"


  # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Specify the location from where the source should be retrieved.
  #  Supports git, hg, bzr, svn and HTTP.
  #

  spec.source       = { :git => "http://EXAMPLE/MyComponent.git", :tag => "#{spec.version}" }


  # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  CocoaPods is smart about how it includes source code. For source files
  #  giving a folder will include any swift, h, m, mm, c & cpp files.
  #  For header files it will include any header in the folder.
  #  Not including the public_header_files will make all headers public.
  #

  spec.source_files  = "Classes", "Classes/**/*.{h,m}"
  spec.exclude_files = "Classes/Exclude"

  # spec.public_header_files = "Classes/**/*.h"


  # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  A list of resources included with the Pod. These are copied into the
  #  target bundle with a build phase script. Anything else will be cleaned.
  #  You can preserve files from being cleaned, please don't preserve
  #  non-essential files like tests, examples and documentation.
  #

  # spec.resource  = "icon.png"
  # spec.resources = "Resources/*.png"

  # spec.preserve_paths = "FilesToSave", "MoreFilesToSave"


  # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  Link your library with frameworks, or libraries. Libraries do not include
  #  the lib prefix of their name.
  #

  # spec.framework  = "SomeFramework"
  # spec.frameworks = "SomeFramework", "AnotherFramework"

  # spec.library   = "iconv"
  # spec.libraries = "iconv", "xml2"


  # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  #
  #  If your library depends on compiler flags you can set them in the xcconfig hash
  #  where they will only apply to your library. If you depend on other Podspecs
  #  you can include multiple dependencies to ensure it works.

  # spec.requires_arc = true

  # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
  # spec.dependency "JSONKit", "~> 1.4"

end

4.编辑 Podspec 文件

打开 YourLibrary.podspec 文件,在编辑器中进行修改,以符合你的库的具体情况。以下是 Podspec 文件的一个例子及其解释:

Pod::Spec.new do |s|
  s.name         = "YourLibrary"
  s.version      = "0.0.1"
  s.summary      = "A short description of YourLibrary."
  s.description  = <<-DESC
                   An optional longer description of YourLibrary.
                   DESC
  s.homepage     = "http://example.com/YourLibrary"
  s.license      = { :type => "MIT", :file => "LICENSE" }
  s.author       = { "Your Name" => "you@example.com" }
  s.source       = { :git => "https://github.com/yourusername/YourLibrary.git", :tag => "#{s.version}" }
  s.source_files = "Sources/**/*.{h,m,swift}"
  s.platform     = :ios, '10.0'
  s.swift_version = '5.0'
end
  • name: 库的名称。
  • version: 库的版本号。这个版本应该与 Git 标签(tag)一致。
  • summary: 库的简短描述。
  • description: 库的详细描述。
  • homepage: 库的主页 URL。
  • license: 许可证类型和文件位置。
  • author: 库的作者信息。
  • source: 指定库的源代码位置,通常是一个 Git 仓库。
  • source_files: 指定包括在库中的源文件。
  • platform: 指定库支持的平台及最低版本。
  • swift_version: 指定所需的 Swift 版本。

注意更新你组件库中的标签或分支

MyComponent.podspec 文件中的 s.source 参数,确保其指向正确的 URL 和分支或标签。

先确保你的组件库有你配置这个分支或标签,然后你再配置分支的名称或tag。

标签(Tag):

标签是指向 Git 仓库中某一特定提交的引用,通常用于标记发布点(如版本发布)。标签是静态的,指向特定的提交,不会随着更多的提交而变化。

在 podspec 文件中使用标签,通常意味着你指定了一个稳定的、用于发布的版本。这是最常见的用法,因为这确保了项目的依赖是固定且可预测的。例如:

s.source = { :git => 'https://gitee.com/fzym/my-component.git', :tag => '0.0.1' }

 分支(Branch):

分支是用于开发新功能、修复错误或进行实验而创建的代码的独立线路。创建分支可以让你在不影响主线(通常是 master 或 main 分支)的情况下开发和测试代码。

在 podspec 文件中指定分支,意味着 CocoaPods 将从这个特定分支拉取代码。这通常用于开发阶段,当你想要使用最新的尚未发布的代码时。

s.source = { :git => 'https://gitee.com/fzym/my-component.git', :branch => 'develop' }

这里,develop 分支可能包含最新的开发中的功能和修复。

 

5.验证 Podspec 文件

在完成编辑后,你需要验证 Podspec 文件来确保配置无误:

$ pod lib lint

 这个命令将检查你的 Podspec 文件是否有错误或者遗漏的必要信息。如果一切顺利,你将看到 "passed validation" 的消息。

6.将 Podspec 推送到你的私有 Spec 仓库

推送到私有 Spec 仓库:

一旦 Podspec 文件准备好并且验证通过,可以将其添加到你的私有 Spec 仓库:

$ pod repo add PrivateRepoName https://github.com/yourusername/PrivatePodSpecs.git
$ pod repo push PrivateRepoName YourLibrary.podspec

 这里 PrivateRepoName 是你给你的私有 Spec 仓库设定的本地名称。

重命名仓库:

如果需要重命名仓库,你可以这样做:

$ pod repo remove OldPrivateRepoName
$ pod repo add NewPrivateRepoName https://github.com/yourusername/PrivatePodSpecs.git

查看所有已添加的仓库:

如果你忘记了你为私有仓库设置的本地别名 PrivateRepoName,你可以很容易地查看你的 CocoaPods 配置来找到所有已添加的私有仓库及其别名。这可以通过在终端运行一个简单的命令来完成。

$ pod repo list

6.使用你的私有库

在项目的 Podfile 中指定你的私有 Spec 仓库和库:

source 'https://github.com/yourusername/PrivatePodSpecs.git'
source 'https://cdn.cocoapods.org/'

platform :ios, '10.0'

target 'YourTarget' do
  use_frameworks!
  pod 'YourLibrary', '~> 0.0.1'
end

然后运行:

$ pod install

7.更新库

当你需要更新你的库时:

  • 更新你的库代码。
  • 修改 Podspec 文件中的版本号,并确保更新 tag。
  • 推送新代码到你的库的 Git 仓库,并创建相应的新 tag。
  • 将更新后的 Podspec 推送到私有 Spec 仓库:
$ pod repo push PrivateRepoName YourLibrary.podspec
  • 在使用该库的项目中,运行 pod update 来拉取最新版本。

8.管理权限

由于你的库和 Spec 仓库是私有的,确保只向需要的团队成员和合作者提供访问权限。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/576980.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

电商API数据采集接口||大数据的发展,带动电子商务产业链,促进了社会的进步

最近几年计算机技术在诸多领域得到了有效的应用&#xff0c;同时在多方面深刻影响着我国经济水平的发展。除此之外&#xff0c;人民群众的日常生活水平也受大数据技术的影响。 主流电商API数据采集接口||在这其中电子商务领域也在大数据技术的支持下&#xff0c;得到了明显的进…

关于我在 uniapp 开发过程中遇到的问题(更新中...)

目录 uniapp 勾选自带的隐私政策 出现的问题 是否忽略版本兼容检查提示 勾选了uniapp的消息推送 打包后弹出 push module was not added when packaging, please refertohttps://ask.dcloud.net.cn /article/283 关于uniapp的真机调试 一直等待问题 或者 正在建立链接 在…

机器人前馈控制MATLAB实现

在机器人控制中&#xff0c;前馈控制是一种常用的方法&#xff0c;用于补偿系统中的已知动态。前馈控制通常与反馈控制结合使用&#xff0c;以提高系统的跟踪性能和响应速度。在MATLAB中实现机器人前馈控制涉及几个步骤&#xff0c;包括系统建模、设计前馈控制器、实现控制算法…

【前后端】django与vue的结合使用

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、前后端分离的简介二、django与vue的结合使用三、总结 前言 随着开发语言及人工智能工具的普及&#xff0c;使得越来越多的人会主动学习使用一些开发工具&a…

一、Django 初识

简介 Django 是一个用于构建 Web 应用程序的高级 Python Web 框架。 版本对应 不同版本的django框架是基于特定的不同的python版本开发的&#xff0c;所以不同版本的django框架要正常执行功能只能安装特定的python版本 Django安装 安装 Django # 全局安装 pip install dj…

金融案例:统一查询方案助力数据治理与分析应用更高效、更安全

随着企业数据规模的增长和业务多元化发展&#xff0c;海量数据实时、多维地灵活查询变成业务常见诉求。同时多套数据库系统成为常态&#xff0c;这既带来了数据管理的复杂性&#xff0c;又加大了数据使用的难度&#xff0c;面对日益复杂的数据环境和严格的数据安全要求&#xf…

苹果发布开源模型;盘古大模型5.0将亮相;英伟达将收购 Run:ai

苹果首次发布开源语言模型 近期&#xff0c;苹果在 Hugging Face 发布了 OpenELM 系列模型。OpenELM 的关键创新是逐层扩展策略&#xff0c;该策略可在 transformer 模型的每一层中有效地分配参数&#xff0c;从而提高准确性。 与具有统一参数分配的传统语言模型不同&#xff…

rabbitmq集群配置

1&#xff0c;配置环境变量 MY_POD_NAME&#xff1a;当前Pod的名称 RABBITMQ_ERLANG_COOKIE&#xff1a;设置Erlang Cookie用于节点间通信安全验证&#xff0c;值来自/nfs/rabbitmq/lib/.erlang.cookie文件内容 RABBITMQ_NODENAME&#xff1a;根据Pod名称动态生成了RabbitMQ…

前端到全栈进阶之“前端框架”

从前端入门到全栈-系列介绍 你会学到什么&#xff1f; 可能学不到什么东西&#xff0c;该系列是作者本人工作和学习积累&#xff0c;用于复习 系列介绍 现在的 Web 前端已经离不开 Node.js&#xff0c;我们广泛使用的 Babel、Webpack、工程化都是基于 Node 的&#xff0c;各…

k8s-身份认证与权限

认证概述 Kubernetes作为一个分布式集群的管理工具&#xff0c;保证集群的安全性是其一个重要的任务。所谓的安全性其实就是保证对Kubernetes的各种客户端进行认证和鉴权操作。 在Kubernetes集群中&#xff0c;客户端通常有两类&#xff1a; User Account&#xff1a;一般是独…

vue elementui el-table 表格里边展示四分位图

vue elementui el-table 表格里边展示四分位图 直接上代码&#xff08;效果图在文章末尾&#xff09;&#xff1a; 父组件&#xff1a; <template> <el-table size"small":header-cell-style"headerCellStyle()"style"width: 100%;"…

Linux平台Unity下RTMP|RTSP低延迟播放器技术实现

技术背景 国产操作系统对于确保信息安全、促进技术创新、满足特定需求以及推动经济发展等方面都具有重要意义&#xff0c;多以Linux为基础二次开发。2014年4月8日起&#xff0c;美国微软公司停止了对Windows XP SP3操作系统提供支持&#xff0c;这引起了社会和广大用户的广泛关…

Spark 基础

/* Why Spark一、MapReduce编程模型的局限性1、繁杂&#xff1a;只有Map和Reduce两个操作&#xff0c;复杂的逻辑需要大量的样板代码2、处理效率低&#xff1a;2.1、Map中间结果写磁盘&#xff0c;Reduce写HDFS&#xff0c;多个Map通过HDFS交换数据2.2、任务调度与启动开销大3、…

C++中的queue(容器适配器)

目录 一、成员函数 一、构造函数 二、入栈 push 三、出栈 pop 四、判空 empty 五、队列大小 size 六、取队头元素 front 七、取队尾元素 back 八、入栈 emplace 九、交换函数 swap 二、非成员函数重载 一、关系运算符重载 二、交换函数 swap C中的queue不再是容…

HWOD:单词倒排

一、知识点 此题&#xff0c;笔者自己写的代码中flag的设置极为精妙 二、题目 1、描述 对字符串中的所有单词进行倒排。 说明&#xff1a; (1)、构成单词的字符只有26个大写或小写英文字母&#xff1b; (2)、非构成单词的字符均视为单词间隔符&#xff1b; (3)、要求倒…

Visual Studio 对 C++ 头文件和模块的支持

在 C 编程领域&#xff0c;头文件和模块的管理有时候确实比较令人头疼。但是&#xff0c;有许多工具和功能可以简化此过程&#xff0c;提高效率并减少出错的可能性。下面是我们为 C 头文件和模块提供的几种工具的介绍。 构建明细 通过菜单栏 Build > Run Build Insights&a…

uni-app中配置自定义条件编译

前提&#xff1a;官网提供的自定义编译不满足条件 package.json | uni-app官网 下文&#xff1a;不详细写&#xff0c;主要写关键思路 package.json文件 主要看scripts的执行命令&#xff0c;其他依赖就是用vue-cli方式创建uni-app项目生成的 {"name": "un…

命令行启动pytest自动化程序时,程序卡住不动了,不继续往下执行了

一、问题描述 在执行pytestallure自动化测试工具的时候&#xff0c;命令行启动程序时&#xff0c;程序卡住不继续往下执行&#xff0c;如下图所示。 代码主函数如下&#xff1a; 二、解决方法 测试客户项目时遇到2次此类问题&#xff0c;2次问题原因不一样。 原因一&#xf…

3d合并的模型为什么没有模型---模大狮模型网

在3D建模中&#xff0c;合并模型是常见的操作&#xff0c;它可以将多个模型合并成一个整体。然而&#xff0c;有时候在合并后却发现部分模型消失了&#xff0c;这可能会让人感到困惑和失望。本文将探讨为什么合并的3D模型中会出现没有模型的情况&#xff0c;并提供一些解决方法…

API和微服务设计的优化方式有哪些?

在构建响应迅速、用户体验良好的应用程序中&#xff0c;API性能的优化至关重要。在构建高性能的API时&#xff0c;采取综合策略是至关重要的。通过采用一系列策略&#xff0c;我们可以确保API在处理请求时高效运行&#xff0c;提供流畅的服务。 一、API和微服务设计的优化可以…
最新文章