为了账号安全,请及时绑定邮箱和手机立即绑定

ios学习笔记--git私有仓库的创建和使用

标签:
iOS

一、CocoaPods私有库创建
这里提倡用Coding不仅仅是快,而且免费,GitHub私有库慢而且收费
一、创建私有Spec repo https://git.coding.net/ZKReadStone/ZKSpecs.git
$ open ~/.cocoapods/repos //打开.cocoapods/repo文件夹 查看master文件夹结构如下图:图片描述

1.创建私有Spec repo远程仓库,如下图

图片描述

图片描述

图片描述

二、创建项目仓库(https://git.coding.net/ZKReadStone/LoginModule.git)的时候只要填下图的几项
图片描述

注意:下图这两项不要选,因为项目工程通过下面命令创建

pod lib create [项目名]

$pod lib create LoginModule
图片描述

图片描述
命令执行完毕后工程目录如下图,可见项目根目录里已经有LICENSE和README.md文件,所以上面两项不要选

What language do you want to use?? [ Swift / ObjC ]

ObjC
第一个问题是问你选择Swift还是Objc构建项目。此教程 选的是ObjC

Would you like to include a demo application with your library? [ Yes / No ]

Yes
第二个问题问你是否需要创建一个Demo项目,此教程选的是Yes

Which testing frameworks will you use? [ Specta / Kiwi / None ]

Specta
第三个问题让你是否选择一个测试框架,此教程选 Specta

Would you like to do view based testing? [ Yes / No ]

Yes
第四个问题是否基于View测试,选Yes

What is your class prefix?

ZK
第五个问题是询问 类的前缀,设为ZK

成功后会在目录中创建好一个LoginModule工程,结构如下:
图片描述

把Classes文件夹里面的ReplaceMe.m文件删掉,替换成自己的代码

配置podspec文件并提交到私有Repo仓库

Pod::Spec.new do |s|
s.name = 'LoginModule'
s.version = '0.1.0'
s.summary = '登录注册模块'

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
登录注册模块,方便模块化开发。。。。
DESC
s.homepage = 'https://coding.net/user'

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

s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'zhangkangreadstone@163.com' => 'zhangkangjiqi@163.com' }
s.source = { :git => 'https://git.coding.net/ZKReadStone/LoginModule.git', :tag => s.version.to_s }

s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.ios.deployment_target = '8.0'
s.source_files = 'LoginModule/Classes/*/'

s.resource_bundles = {
'LoginModule' => ['LoginModule/Assets/*.png']
}
s.public_header_files = 'Pod/Classes/*/.h'

s.frameworks = 'UIKit'

s.dependency 'AFNetworking', '~> 2.3'

end

注意:
s.source = { :git => 'https://git.coding.net/ZKReadStone/LoginModule.git', :tag => s.version.to_s } 中https://git.coding.net/ZKReadStone/LoginModule.git是项目仓库,不是私有repo库
s.source_files = 'LoginModule/Classes/*/’ 表示的是根目录下LoginModule文件夹Classes文件里所有文件

配置完成,用$ pod lib lint检测配置有没有错误

-> LoginModule (0.1.0)

LoginModule passed validation.

表示配置podspec无误,检查通过

项目提交到git仓库:
$ git add .

$ git commit -m "first commit"

$ git remote add origin https://git.coding.net/ZKReadStone/LoginModule.git

$ git commit -a -m "PodTest 0.1"
$ git pull origin master

$ git push origin master

给项目打标记

$ git tag -m “New Tag” ‘0.1.0’

$ git push -tags

注册pod trunk
$ pod trunk register 你的有效的邮箱@163.com '你的昵称'
去上面你输入的邮箱里,点击no-reply里面的验证链接

拉取远程Repo仓库到本地,会看到本地 $ open ~/.cocoapods/repos
pod repo add [私有项目名(repo仓)] [podspe仓clone地址]
$ pod repo add ZKSpecs https://git.coding.net/ZKReadStone/ZKSpecs.git

没有问题,就可以把podspec文件提交到远程仓库

pod repo push [Repo名] [podspec 文件名字]

$ pod repo push ZKSpecs LoginModule.podspec

再去看我们的Spec Repo远端仓库 也就是私有Repo仓库,也有了一次提交,这个podspec也已经被Push上去了。

使用pod search命令就可以查到我们自己的库了.

打开Example工程目录Podfile文件:

source 'https://git.coding.net/ZKReadStone/ZKSpecs.git'
use_frameworks!

target 'TestLoginDemo' do
platform :ios, '8.0'
pod 'LoginModule', '0.1.0'
end

下面就是正常的Cocapods的使用

点击查看更多内容
1人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
移动开发工程师
手记
粉丝
32
获赞与收藏
322

关注作者,订阅最新文章

阅读免费教程

感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消