建立私有仓库

首先两个概念,版本库,代码库.以公共的为例.

CocoaPods (https://github.com/CocoaPods/CocoaPods)为版本库.

AFNetWorking (https://github.com/AFNetworking/AFNetworking)则为代码库.

首先建立自己的私有Repo.

我这边直接在GitHub上建立个(https://github.com/KayCm/PrivateRepo)

使用如下将私有版本库添加到本地(如若协同编码,其他人也需要进行添加),

pod repo add PrivateRepo git@github.com:KayCm/PrivateRepo.git

进入该目录,检查是否有自己的私有版本库,也就是PrivateRepo

~/.cocoapods/repos

 

接着进行私有代码库操作.

同样GitHub建立代码仓库,不要忘记添加License(https://github.com/KayCm/RepoItem)

将代码库克隆到本地..添加你的代码文件,以及podspec文件(代码库名.podspec).

通过如下命令创建并修改其属性

pod spec create RepoItem

附我这边的podspec文件

#
#  Be sure to run `pod spec lint NativeVideoTemplet.podspec' to ensure this is a
#  valid spec and to remove all comments including this before submitting the spec.
#
#  To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
#  To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

    s.name         = "RepoItem" # 项目名称
    s.version      = "0.0.1"        # 版本号 与 你仓库的 标签号 对应
    s.license      = { :type => "MIT", :file => "LICENSE" }          # 开源证书
    s.summary      = "私有代码库" # 项目简介

    s.homepage     = "http://M1989.COM" # 仓库的主页
    s.source       = { :git => "https://github.com/KayCm/RepoItem.git", :tag => "#{s.version}" }#你的仓库地址,不能用SSH地址
    s.source_files = "RepoItem/*.{h,m}" # 你代码的位置, RepoItem/*.{h,m} 表示 RepoItem 文件夹下所有的.h和.m文件
    s.requires_arc = true # 是否启用ARC
    s.platform     = :ios, "8.0" #平台及支持的最低版本
    # s.frameworks   = "UIKit", "Foundation" #支持的框架
    # s.dependency   = "AFNetworking" # 依赖库

    # User
    s.author             = { "BY" => "rain@m1989.com" } # 作者信息
    s.social_media_url   = "http://M1989.COM" # 个人主页

    # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
    # s.dependency "Masonry" 所依赖的库1
    # s.dependency "AFNetworking", "~> 3.0" 所依赖的库2

end

 

完成后,继续执行

pod lib lint

或添加 --private 或者 --allow-warnings

pod lib lint --private

 

成功后,出现如下提示,我这边缺了license,不过不太要紧.

 -> RepoItem (0.0.1)

RepoItem passed validation.

[!] Unable to read the license file `/Users/kaycm/Documents/WorkCode/RepoItem/LICENSE` for the spec `RepoItem (0.0.1)`

[!] Unable to read the license file `/Users/kaycm/Documents/WorkCode/RepoItem/LICENSE` for the spec `RepoItem (0.0.1)`

 

下一步将代码库push到GitHub上.千万不要忘记打tag,tag与你在podspec文件里写的版本号相同.

 

最后将描述文件,也就是RepoItem.podspec推送到版本库.

pod repo push PrivateRepo RepoItem.podspec  

 

上述命令成功后,直接使用pod search 查询,查询到说明已经添加到私有库

pod search RepoItem

 

最后如何使用.

如果只使用私人版本库.在podfile顶部添加

source 'https://github.com/KayCm/PrivateRepo'

如果需要公有版本库则再添加

source 'https://github.com/CocoaPods/Specs.git'

完成podfile如下

source 'https://github.com/KayCm/PrivateRepo'
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

target 'NativeVideoTemplet' do
    pod 'GPUImage'
    pod 'MBProgressHUD', '~> 1.1.0'
    pod 'Masonry'
    pod 'AFNetworking', '~> 3.0'
    pod 'SDWebImage', '~> 4.0'
    pod 'CircleProgressBar','~> 0.32'
end

posted @ 2018-03-01 11:12  NGI.  阅读(977)  评论(0编辑  收藏  举报
GitHub | M1989