CocoaPods私有库Steps

2017-11-01  本文已影响79人  该简书已经停止更新

1.创建私有仓库

coding.netOSChinaGitHub或者自己搭建的Git服务器上创建一个私有仓库,然后在本地添加仓库

pod repo add LYSpecs https://git.coding.net/CodingZero/LYSpecs.git

2.创建私有库

创建私有库模板

pod lib create VenderName
hat language do you want to use?? [ Swift / ObjC ]
> 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?
> LY

3.更新发布私有库

git add -A && git commit -m "Release 1.0.0"
git tag '1.0.0'
git push --tags
git push origin master
pod repo push LYSpecs VenderName.podspec --allow-warnings --verbose
// --allow-warnings : 允许 警告,有一些警告是代码自身带的。
// --use-libraries  : 私有库、静态库引用的时候加上
// —-verbose : lint显示详情

4.使用私有库

// GitHub地址
source 'https://github.com/CocoaPods/Specs.git'
# ...相关库
// 私有库地址
source 'https://git.coding.net/CodingZero/LYSpecs.git'
# ...私有库
pod 'VenderName'
pod 'VenderName', :path => '../' # 指定路径

然后在Example工程目录下执行pod update命令安装依赖,打开项目工程,可以看到库文件都被加载到Pods子项目中了
不过它们并没有在Pods目录下,而是跟测试项目一样存在于Development Pods/VenderName中,这是因为我们是在本地测试,而没有把podspec文件添加到Spec Repo中的缘故。

5.podspec文件配置说明

#
# Be sure to run `pod lib lint VenderName.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             = 'VenderName'
  #版本号
  s.version          = '0.1.0'
  #简介
  s.summary          = '这个是我的私有库项目Demo.'

# 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
  这个是教程的 私有库项目 学习Demo. (主要:比s.summary要长)
                       DESC
  #主页,这里要填写可以访问到的地址,不然验证不通过
  s.homepage         = 'https://coding.net/CodingZero/VenderName'

  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'

  #开源协议

  s.license          =   { :type => 'MIT', :file => 'LICENSE' }

  #作者
  s.author           = { 'DeveloperLY' => 'coderyliu@gmail.com' }

  #项目地址,这里不支持ssh的地址,验证不通过,只支持HTTP和HTTPS,最好使用HTTPS。
  #这里的s.source须指向存放源代码的链接地址,而不是托管spec文件的repo地址
  s.source           = { :git => 'https://coding.net/CodingZero/VenderName.git', :tag => "0.1.0" }

  #s.social_media_url = 'http://weibo.com/lycoder'

  #支持的平台及版本
  s.ios.deployment_target = '7.0'

  #代码源文件地址,**/*表示Classes目录及其子目录下所有文件,如果有多个目录下则
  #用逗号分开,如果需要在项目中分组显示,这里也要做相应的设置

  s.source_files = "VenderName/Classes/**/*"

  #资源文件地址
  # s.resource_bundles = {
  #   'MyLib' => ['VenderName/Assets/*.png']
  # }

  #公开头文件地址
  #s.public_header_files = 'VenderName/Classes/**/*.h'

  #所需的framework,多个用逗号隔开
  s.frameworks = 'UIKit'

  #依赖关系,该项目所依赖的其他库,如果有多个需要填写多个s.dependency
  # s.dependency 'AFNetworking', '~> 3.1'
end
上一篇下一篇

猜你喜欢

热点阅读