pod 建立私有库

1.使用工具及版本

 xcode 8.0   cocoapods 1.1.0.rc.2 (现在属于bate版)  

如果现在使用的的xcode 8.0 而cocoapods 版本较低 会报错:

xcodebuild: error:'App.xcworkspace'doesnotexist. ->PodPrivatelibraries (0.1.0)    - ERROR | [iOS] xcodebuild: Returned an unsuccessfulexitcode.    - NOTE  | [iOS] xcodebuild:  xcodebuild: error:'App.xcworkspace'doesnotexist.

解决方法  pod update --pre 

检测pod 版本 gem list 如果 cocoapods 1.1.0.bate 请查看 gem source -l 可能是淘宝影像。 如果有条件的可以翻墙使用 --pre 是测试版本

source地址不同结果显示cocoapods版本会有差别

✗ gem sources--removehttps://ruby.taobao.org/source

✗ gem sources -a https://rubygems.org/source

✗ gem update --pre

2.创建私有库

(1).准备两个gitHUb的 仓库 一个 用于储存版本管理  一个是用于创建私有库

1.https://ouxuesen@github.com/ouxuesen/PodPrivatelibraries.git

2.https://ouxuesen@github.com/ouxuesen/PodPrivatelibrariesTest.git

创建本地库 pod lib create PodPrivatelibraries 根据提示创建

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

# Be sure to run `pod lib lint PodPrivatelibraries.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            = 'PodPrivatelibraries'

s.version          = '0.1.0'

s.summary          = 'ou xue sen'

s.description      = <<-DESC

TODO: Add long description of the pod here.

DESC

s.homepage        = 'https://github.com/ouxuesen/PodPrivatelibraries'

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

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

s.author          = { 'ouxuesen' => 'ouxuesen@le.com' }

s.source          = { :git => 'https://github.com/ouxuesen/PodPrivatelibraries.git', :tag => s.version.to_s }

s.ios.deployment_target = '8.0'

s.source_files = 'PodPrivatelibraries/Classes/**/*.{h,m}'

s.resource_bundles = {

'MyPodBundle' => ['PodPrivatelibraries/Classes/**/*.xib']

}

end

验看本地库是否成功

进入到 Example目录下更新pod    pod update

验证 .podspec文件的合法性 进入.podspec文件所在目录

pod lib lint  或者pod --verbose lib lint 或者 pod --no-clear lib lint

输出 PodPrivatelibraries.podspec passed validation.  表示验证成功  有error 的提示按照提示一般去做都没什么太大问题

验证远程库

pod spec lint

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

创建私有库 创建成功 会在~/.cocoapod/repo目录下看到PodPrivatelibrariesTest的空白文件夹

pod repo add testSpecs https://ouxuesen@github.com/ouxuesen/PodPrivatelibrariesTest.git

私用库中添加工具库

pod repo push testSpecs PodPrivatelibrariesTest.podspec

以后每次 版本变更 或者修改都可以使用该方法 私有库的更新

测试其是否可用

建立一个普通的工程命名为TestPodFrameworkDemo,在目录下添加podfile文件,添加pod 'YohunlUtilsPod'

$ pod init  建立podfile文件

修改文件podfile内容为下

target 'TestPodFrameworkDemo' do

pod 'PodPrivatelibrariesTest'

end

执行

$ pod install

这个时候,得到提示

Updating local specs repositories

Analyzing dependencies

[!] Unable to find a specification for `PodPrivatelibraries (~> 0.1.0)`

其实是这样的,如果你不指定的话,pod install只会在master下搜索有没有,而我们的spec文件在yohunlSpecs下面,当然找不到了!

source 'https://github.com/CocoaPods/Specs.git'  #官方仓库的地址

source 'https://github.com/ouxuesen/PodPrivatelibrariesTest.git'

target "DemoPod" do

pod 'PodPrivatelibraries', '~> 0.1.0'

end

默认情况下,如果你不添加source的话,系统会默认使用https://github.com/CocoaPods/Specs.git官方源,但是当你添加了source后,系统就不再自动搜索 官方源,所以这两句都必须添加!!!!!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、创建的github仓库原文地址 1 进入Github网站www.github.com登陆自己的账号后 2 建立...
    freesan44阅读 3,991评论 2 12
  • 项目组件化、平台化是技术公司的共同目标,越来越多的技术公司推崇使用pod管理第三方库以及私有组件,一方面使项目架构...
    swu_luo阅读 22,382评论 0 39
  • 网上将自己的项目做成Pod 的文档很多,但是有些文档已经很老了,不适合新手上手,经过这两天的研究我决定还是自己写一...
    黄鱼儿啦啦啦阅读 7,203评论 10 17
  • Ruby 安装 要安装cocospods 首先需要安装ruby,可以先安装xcode,再安装macport ,最后...
    山天大畜阅读 1,916评论 0 1
  • 昨日踏歌行囊负,春风翘眉发蓬蒿,然精神颓废,无暇昏睡兮,不曾饭饱兮,孤寂愁金兮,远山斜阳归冢兮,灯火通明,车辆穿...
    焦志欢阅读 199评论 0 3