热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CocoaPods私有库搭建的记录

前言随着项目的业务增加以及马甲包进度的跟进,一些重复的独立业务以私有库的方式引入到项目中对于项目进度的开发就显得越发的迫切了,本文主要记录自己搭建私有

前言

随着项目的业务增加以及马甲包进度的跟进,一些重复的独立业务以私有库的方式引入到项目中对于项目进度的开发就显得越发的迫切了,本文主要记录自己搭建私有库时的整个流程,以防后面再次搭建时忘记,方便自己查阅。

整个记录流程中私有库的存储是在码云中,也可以在公司自己的git仓库中,自己选择即可。

私有库的搭建涉及到创建索引库和私有库,这里解释下两者:

索引库:存放spec文件的仓库,找到代码位置的索引。

私有库:存放代码的仓库。

两者像指针和对象的关系,指针中存放对象的地址,可以通过指针找到对象。两个仓库创建后,通过命令行将两者关联起来,这样整个私有库的搭建过程就完成了。


1、创建索引库

创建的这个空的仓库,是用来存放我们自己所有的私有库的 spec 文件, 就如同官方的 https://github.com/CocoaPods/Specs 是用来存放所有官方的 specs 文件一样。


2、将索引库添加到本地cocoapods仓库
 

通过命令行添加自己的索引库到本地仓库

pod repo add wyonSpec https://gitee.com/wyon_wang/wyon-spec.git

添加完毕后查看本地仓库

以上就创建完成了一个自己的索引仓库,该仓库只存放各组件的索引文件,不存放代码!!!


3、创建工程模板

wyondeMacBook-Pro:~ wyon$ cd /Users/wyon/Desktop/TestProject
wyondeMacBook-Pro:TestProject wyon$ pod lib create YGTool
Cloning `https://github.com/CocoaPods/pod-template.git` into `YGTool`.
Configuring YGTool template.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.------------------------------To get you started we need to ask a few questions, this should only take a minute.If this is your first time we recommend running through with the guide: - https://guides.cocoapods.org/making/using-pod-lib-create.html( hold cmd and double click links to open in a browser. )What platform do you want to use?? [ iOS / macOS ]> iOSWhat language do you want to use?? [ Swift / ObjC ]> ObjCWould you like to include a demo application with your library? [ Yes / No ]> YESWhich testing frameworks will you use? [ Specta / Kiwi / None ]> NoneWould you like to do view based testing? [ Yes / No ]> NoWhat is your class prefix?> YG_
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m Running pod install on your new library.Analyzing dependencies
Downloading dependencies
Installing YGTool (0.1.0)
Generating Pods project
Integrating client project[!] Please close any current Xcode sessions and use `YGTool.xcworkspace` for this project from now on.
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.[!] Your project does not explicitly specify the CocoaPods master specs repo. Since CDN is now used as the default, you may safely remove it from your repos directory via `pod repo remove master`. To suppress this warning please add `warn_for_unused_master_specs_repo => false` to your Podfile.Ace! you're ready to go!We will start you off by opening your project in Xcodeopen 'YGTool/Example/YGTool.xcworkspace'To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.
To learn more about creating a new pod, see `https://guides.cocoapods.org/making/making-a-cocoapod`.
wyondeMacBook-Pro:TestProject wyon$

通过该命令行自动创建一个模板工程,其中包含我们所需的索引文件,格式为.podspec。创建完后会自动打开该工程。


4、添加我们的组件到指定目录

这样我们本地私有库完成,接下来制作远端仓库


5、将本地库上传码云 

这里是新创建一个项目,为我们真正存放代码的仓库。
我们可以根据码云中的提示上传模板文件

  通过命令行上传组件文件

$ git add .
$ git commit -m '模板工程初始化'
$ git push -u origin master

之后我们修改下模板工程中的.podspec文件,如下图 


6、验证spec文件

注意这里我们上次的代码一定要走的通,不然会校验失败。

wyondeMacBook-Pro:YGTool wyon$ cd /Users/wyon/Desktop/TestProject/YGTool
wyondeMacBook-Pro:YGTool wyon$ pod lib lint --private-> YGTool (1.0.0)- NOTE | xcodebuild: note: Using new build system- NOTE | xcodebuild: note: Using codesigning identity override: -- NOTE | xcodebuild: note: Build preparation complete- NOTE | [iOS] xcodebuild: note: Planning- NOTE | [iOS] xcodebuild: note: Building targets in parallel- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')YGTool passed validation.

验证成功后打分支,这里的分支一定要和.podspec文件中的版本号一致

$ git tag 1.0.0
$ git push --tags

7、私有库和索引库建立关联

pod repo push wyonSpec YGTool.podspec

这样就同步好了远程和本地索引库,到这里私有库搭建完毕,可以通过命令行搜索下自己的仓库查看一下

pod search YGTool



 


推荐阅读
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • CentOS7源码编译安装MySQL5.6
    2019独角兽企业重金招聘Python工程师标准一、先在cmake官网下个最新的cmake源码包cmake官网:https:www.cmake.org如此时最新 ... [详细]
  • 深入解析JVM垃圾收集器
    本文基于《深入理解Java虚拟机:JVM高级特性与最佳实践》第二版,详细探讨了JVM中不同类型的垃圾收集器及其工作原理。通过介绍各种垃圾收集器的特性和应用场景,帮助读者更好地理解和优化JVM内存管理。 ... [详细]
  • QUIC协议:快速UDP互联网连接
    QUIC(Quick UDP Internet Connections)是谷歌开发的一种旨在提高网络性能和安全性的传输层协议。它基于UDP,并结合了TLS级别的安全性,提供了更高效、更可靠的互联网通信方式。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 1.如何在运行状态查看源代码?查看函数的源代码,我们通常会使用IDE来完成。比如在PyCharm中,你可以Ctrl+鼠标点击进入函数的源代码。那如果没有IDE呢?当我们想使用一个函 ... [详细]
  • 数据管理权威指南:《DAMA-DMBOK2 数据管理知识体系》
    本书提供了全面的数据管理职能、术语和最佳实践方法的标准行业解释,构建了数据管理的总体框架,为数据管理的发展奠定了坚实的理论基础。适合各类数据管理专业人士和相关领域的从业人员。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 使用Numpy实现无外部库依赖的双线性插值图像缩放
    本文介绍如何仅使用Numpy库,通过双线性插值方法实现图像的高效缩放,避免了对OpenCV等图像处理库的依赖。文中详细解释了算法原理,并提供了完整的代码示例。 ... [详细]
  • Docker的安全基准
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 本文详细探讨了KMP算法中next数组的构建及其应用,重点分析了未改良和改良后的next数组在字符串匹配中的作用。通过具体实例和代码实现,帮助读者更好地理解KMP算法的核心原理。 ... [详细]
  • 如何在PHPcms网站中添加广告
    本文详细介绍了在PHPcms网站后台添加广告的方法,涵盖多种常见的广告形式,如百度广告和Google广告,并提供了相关设置的步骤。同时,文章还探讨了优化网站流量的SEO策略。 ... [详细]
author-avatar
手机用户2502903481
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有