iOS创建本地私有CocoaPods库

前两篇文章介绍了如何创建一个公有的CocoaPods库,并且更新版本。但有时公司的一些核心代码不想公开出去,就可以创建一个本地私有的CocoaPods库。直接进入主题,创建步骤如下:

1.首先创建一个DemoProject工程,用于测试后面生成的私有库

这里写图片描述

2.使用命令创建私有库,并且按照提示回答几个问题:

pod lib create LTFramework
  • 私有库使用什么语言?
  • 私有库中是否需要包含一个demo工程?
  • 私有库是否需要包含一个测试框架?
  • 私有库的类前缀是什么?

这里写图片描述

3.可以在DemoProject同级目录中看到,私有库工程已经创建好了,并且会自动打开

这里写图片描述

4.在私有库中加入一个分类文件,重新执行命令

pod install

这里写图片描述

5.在DemoProject中添加pod支持,命令如下:

pod init // 1.初始化pod
touch podfile // 2.生成podfile文件
open podfile // 3.打开podfile文件
在podfile文件中添加”LTFramework”私有库路径,再重新执行命令安装私有库:
pod install

这里写图片描述

6.在DemoProject中成功依赖私有库

这里写图片描述

7.使用私有库中的方法

这里写图片描述

8.在pod lib create时可能会出现如下的错误:

JerryMBP:~ Jerry.Yao$ pod lib create LTFramework  
Cloning `https://github.com/CocoaPods/pod-template.git` into `LTFramework`.  
Configuring LTFramework template.  
/Users/Jerry.Yao/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in `require': cannot load such file -- colored2 (LoadError)  
    from /Users/Jerry.Yao/.rvm/rubies/ruby-2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:120:in `require'  
    from /Users/Jerry.Yao/Desktop/Test/LTFramework/setup/TemplateConfigurator.rb:2:in `<top (required)>'  
    from ./configure:5:in `require_relative'  
    from ./configure:5:in `block in <main>'  
    from ./configure:4:in `each'  
    from ./configure:4:in `<main>'  

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.  
To learn more about creating a new pod, see `http://guides.cocoapods.org/making/making-a-cocoapod`. 
解决办法是输入如下两条命令行:
sudo gem install colored2
sudo gem update --system
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值