cocoapods管理私有库

本文介绍了如何使用CocoaPods管理私有库,包括创建git仓库,管理私有库,配置Podspec文件,以及在项目中引用私有库的方法。参照提供的cocoapods相关教程进行操作。

参考文章
http://www.cocoachina.com/ios/20150228/11206.html
http://blog.csdn.net/yohunl/article/details/48471489

准备工作

1、有自己的git仓库
2、需要管理的私有库

在git服务器上新建一个私有库MyPrivateCocoaRepo

$pod repo add MyPrivateCocoaRepo https://git.oschina.net/huanghehg/MyPrivateCocoaRepo.git
Cloning spec repo `MyPrivateCocoaRepo` from `https://git.oschina.net/huanghehg/MyPrivateCocoaRepo.git`

将自己的需要管理的库克隆到本地,cd到目录下,打上tag

$git clone https://git.oschina.net/huanghehg/MyTool.git
$cd ~/MyTool
$git tag 0.0.6
$git push --tags

在该目录下创建spec文件,vim

$pod spec create MyTool https://git.oschina.net/huanghehg/MyTool.git
$vim MyTool.podspec

删除注释,不删除也可以但是看起来不方便

Pod::Spec.new do |s|
  s.name             = "MyTool"    #名称
  s.version          = "0.1.0"             #版本号
  s.summary          = "Just Testing. MyTool"     #简短介绍,下面是详细介绍
  s.description      = <<-DESC
                       Testing Private Podspec.
                       *it is just a test file
                       DESC
  s.homepage         = "https://git.oschina.net/huanghehg/MyTool.git"                        #主页,这里要填写可以访问到的地址,不然验证不通过
  s.license          = 'MIT'              #开源协议
  s.author           = { "huanghehg" => "huanghehg@163.com" }            #作者信息
  s.source           = { :git => "https://git.oschina.net/huanghehg/MyTool.git", :tag => "0.1.0" }      #项目地址,这里不支持ssh的地址,验证不通过,只支持HTTP和HTTPS,最好使用HTTPS
  s.platform     = :ios, '7.0'            #支持的平台及版本
  s.requires_arc = true                   #是否使用ARC,如果指定具体文件,则具体的问题使用ARC

  s.source_files = 'Pod/Classes/**/*'     #代码源文件地址,**/*表示Classes目录及其子目录下所有文件,如果有多个目录下则用逗号分开,如果需要在项目中分组显示,这里也要做相应的设置
  s.resource_bundles = {
    'PodTestLibrary' => ['Pod/Assets/*.png']
  }                                       #资源文件地址

  s.public_header_files = 'Pod/Classes/**/*.h'   #公开头文件地址
  s.frameworks = 'UIKit'                  #所需的framework,多个用逗号隔开
  s.dependency 'AFNetworking', '~> 2.3'   #依赖关系,该项目所依赖的其他库,如果有多个需要填写多个s.dependency
end</twitter_username>

配置完成保存

pod lib lint (验证,不能出现error 如果出现warn 可以在后面跟上--allow-warnings,但不能确保你的类正确)
MyTool passed validation.

然后就可以将spec提交到刚开始的repo里了

pod repo push MyPrivateCocoaRepo MyTool.podspec (--allow-warnings)

此时pod search MyTool
这里写图片描述
就可以在Podfile中使用了


以上是添加到私有库的方法,在项目中使用时需要在Podfile中添加刚刚新建的私有repo地址

source 'https://git.oschina.net/huanghehg/MyPrivateCocoaRepo.git' 
source 'https://github.com/CocoaPods/Specs.git'

添加到public的方法后期会在总结

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值