Cocoapods私有库

http://www.jianshu.com/p/d6a592d6fcedios

1.建立两个什么都不选的远程仓库:(私有公有均可,ReadMe\ignore都不选),一个放代码,一个放源(*.podspec)git

 

2.建立/使用已有NCKSpecs仓库github

1.pod repo add NCKSpecs https://github.com/NicolasKim/NCKSpecs.git (替换NCKSpecs 为本身的,以及后面地址为你的源的git地址)
2.pod repo


NCKSpecs

3.1. 建立NCKFoundation pods以及DEMO工程xcode

pod lib create NCKFoundation (替换NCKFoundation 为你本身的工具名用来之后pod导,例如pod 'MJRefresh' 中的MJRefresh)NCKFoundation

4.在终端进入到Example目录下app



pod install

 




pod install
5.检查
1.后退到podspec文件存在的目录下,输入一下命令:
pod lib lint
pod lib lint --allow-warnings
(提示:NCKFoundation passed validation.)通常是快成功了
常见问题:
1.verify_minimum_git_version!': [!] You need at least git version 1.8.5 to use CocoaPods (Pod::Informative)
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/command.rb:49:in
run
解决方法:修改连接Xcode路径,命令是:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
(sudo xcode-select -switch /Xcode应用所在的文件路径/Contents/Developer)
2.Error:Could not find a device to launch. You requested 'iOS (iOS)', but the available devices were: ["iPad 2 (9.2) - Support - Appium Discuss
verify_minimum_git_version!': [!] You need at least git version 1.8.5 to use CocoaPods (Pod::Informative)
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.2.0/lib/cocoapods/command.rb:49:in
解决方法:1.同上
  2.删除多余的Xcode版本

6.将工程上传的git仓库,并建立tag。
先上传,后加tag,tag必须经过终端加

git add .
$ git commit -s -m "Initial Commit of Library"
$ git remote add origin git@coding.net:wtlucky/podTestLibrary.git           #添加远端仓库
$ git push origin master     #提交到远端仓库
由于podspec文件中获取Git版本控制的项目还须要tag号,因此咱们要打上一个tag,

$ git tag -m "first release" "0.1.0"
$ git push --tags     #推送tag到远端仓库

7.检查

8.上传到源仓库pod spec lint --allow-warnings
pod repo push NCKSpecs NCKFoundation.podspec --allow-warnings (你前面取的名字,和你工程里的那个 XXX.podspec名字)

9.大功告成


10.使用
podfile里面添加你的源地址和官方地址
source '你的源地址'
source 'https://github.com/CocoaPods/Specs.git'//官方地址
而后就
正常导三方同样使用吧!

 

 
私有库引用第三方库时候,头文件在。h里导入会报错,通常在.m里导入

若是在。h导入了,验证用这句pod lib lint xxx.podspec --use-libraries
推用
pod repo push Tool xxx.podspec  --use-libraries

 

11.显示子文件夹s.subspec 'XXXXX' do |ss|ss.ios.deployment_target = '8.0'ss.dependency 'YogaKit'//子文件夹的依赖#ss.public_header_files = '子文件夹名字/**/*.h'ss.source_files = '文件夹名字/Classes/文件夹名字/*.{h,m}'
相关文章
相关标签/搜索