CocoaPods私有库配置笔记

本文介绍如何使用CocoaPods搭建iOS私有组件库,包括创建私有Spec仓库、创建并配置组件库项目、验证及发布组件到私有仓库的全过程。

本文转自:http://www.jianshu.com/p/4b63dfbd8be7

前情提要

公司项目一直在用CocoaPods管理第三方包,自己也想着将项目中的公用模块抽离出来独立的包。所以研究了一下。

准备工作

github创建私有库 如testSpecs.git

pod repo add testSpecs https://github.com/qgg/testSpecs.git

github创建工具库 如QGGImagePicker 注意创建的时候勾选开源协议
命令行创建模版工程
pod lib create QGGImagePicker

根据提示创建完成

XXXXXX$ pod lib create QGGImagePicker
Cloning `https://github.com/CocoaPods/pod-template.git` into `QGGImagePicker`.
Configuring QGGImagePicker template.
------------------------------
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: 
 - http://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and double click links to open in a browser. )
What language do you want to use?? [ ObjC / Swift ]
 > ObjC
Would you like to include a demo application with your library? [ Yes / No ]
 > Yes
Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > None
Would you like to do view based testing? [ Yes / No ]
 > No
What is your class prefix?
 > QGG

完成后打开工程目录如下:工具库主要在红框内容Classes目录下进行开发


1.png


修改工程下的.podspec文件,如

# Be sure to run `pod lib lint QGGImagePicker.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 http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = "QGGImagePicker"
  s.version          = "0.0.1"
  s.summary          = "QGGImagePicker."

# 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
                        A ImagePicker Like WeChat's ImagePicker
                       DESC

  s.homepage         = "https://github.com/infiniteQin/QGGImagePicker.git"
  # s.screenshots     = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
  s.license          = 'MIT'
  s.author           = { "changqin" => "changqin@ixiaopu.com" }
  s.source           = { :git => "https://github.com/infiniteQin/QGGImagePicker.git", :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.platform     = :ios, '7.0'
  s.requires_arc = true

  s.source_files = 'Pod/Classes/**/*','Pod/Classes/**/**/*'
  #s.resource_bundles = {
  #  'QGGImagePicker' => ['Pod/Assets/*.png']
  #}
  #s.resources = "Pod/*.xcassets"

  # s.public_header_files = 'Pod/Classes/**/*.h'
  s.frameworks = "UIKit", "AssetsLibrary"
  s.dependency 'Masonry', '~> 0.6.3'
end

本地验证

pod lib lint

验证成功后推送工程到github给如QGGImagePicker工具库打tag(和podspec中的版本保持一致)

验证远程库

pod spec lint

看到输出如下内容就成功了

QGGImagePicker.podspec passed validation.

私用库中添加工具库

pod repo push testSpecs QGGImgePicker.podspec

使用

pod search QGGImagePicker
Podfile文件添加 pod 'QGGImagePicker', '~> 0.0.1'
pod update --verbose --no-repo-update
注意这时候会报错,解决办法
pod spec lint --sources=‘https://github.com/qgg/testSpecs.git,https://github.com/CocoaPods/Specs'
或者
将~/.cocoapods/repos/testSpecs/下的内容copy到~/.cocoapods/repos/master/Specs下

支持CocoaPods公开库

https://github.com/CocoaPods/Specs.git 下fork一份
将私有库中的.podspec文件转成.json

$ pod ipc spec QGGImagePicker.podspec >> QGGImagePicker.podspec.json

将内容(目录结构如下)添加到CocoaPods/Specs提交待作者审核后即可


内容概要:本文档系统性地介绍了2024年最新提出的两种智能优化算法——青蒿素优化算法与霜冰优化算法(RIME)的原理、实现方法及其性能对比分析,并提供了完整的Matlab代码实现。文档不仅聚焦于核心算法的仿真与验证,还整合了大量前沿科研资源,涵盖微电网优化、风电功率预测、无人机三维路径规划、电动汽车调度、图像融合、负荷预测、通信信号处理、电力系统故障恢复等多个高价值应用场景。所有案例均基于Matlab/Simulink平台进行建模与仿真,强调算法在复杂工程系统中的实际应用能力,旨在为科研人员提供一套从理论到代码再到应用的完整复现体系。; 适合人群:具备一定编程基础和科研背景的研究生、高校教师及工程技术人员,尤其适合从事智能优化算法研究、新能源系统优化、自动化控制、电力系统调度、无人机导航与路径规划等相关领域的研究人员。; 使用场景及目标:①用于高水平学术论文的复现与创新性研究,提升科研效率与成果产出;②应用于复杂工程系统的建模仿真与智能优化设计,如多能互补系统调度、无人机避障路径规划、微电网能量管理等;③作为智能优化算法的教学与学习资料,深入理解现代元启发式算法的设计思想与实现机制。; 阅读建议:建议读者结合文档中提供的Matlab代码与Simulink仿真模型,按照目录结构循序渐进地学习与实践,优先选择与自身研究方向契合的案例进行代码复现,重点关注算法参数设置、收敛曲线分析与多算法对比实验部分,以全面提升算法应用与科研创新能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值