CocoaPods本地私有库、远程私有库使用整理

CocoaPods发布框架到远程公有库

  • 1.编写代码~上传远程仓库

    git init
    git add .
    git commit -m '提交到本地分支'
    
    //关联远程仓库
    git remote add origin 远程仓库url
    //提交代码到远程仓库
    git push origin master
    
    //tag
    git tag //查看版本标签
    git tag -a 1.0.0 -m '1.0.0版本完成' //打完tag 还是处于本地,需要   提交远程代码库
    git push --tags //本地所有tags都提交
    
  • 2.创建podSpec

        pod spec create 文件名称
        //修改podspec文件内容,如下 假设项目名称Test01
        s.name         = "Test01"
        s.version      = "1.0.0"
        s.summary      = "Test01 is a test lib"
    
        s.description  = <<-DESC
        "这是一个长的描述字数要比s.summary长,Test01 is a test lib"
        DESC
    
        s.homepage     = "https://github.com/LouKit/Test01"
    
        s.license      = "Apache License, Version 2.0"
        s.author             = { "LK" => "loukit@qq.com" }
        s.source       = { :git => "https://github.com/LouKit/Test01.git", :tag => "#{s.version}" }
        s.source_files  = "Classes", "Classes/**/*.{h,m}"
    
  • 3.podSpec验证

    pod spec lint
    
  • 4.提交到官方索引库

    //邮箱 密码 填个正确即可,后续需要通过邮箱验证
    pod trunk register loukit@qq.com '随便写'  --verbose
    
  • 5.通过trunk推送podspec文件

    pod trunk push 
    
  • 6.完成

    测试
    pod search Test01
    如果搜索不到,干掉缓存json文件(我电脑路径:/Users/loukit/Library/Caches/CocoaPods/search_index.json)继续搜索即可
    

CocoaPods本地私有库使用

  • 1.创建本地库
  • 2.创建podSpec文件 //pod spec create 文件名称

    修改podspec文件内容同‘CocoaPods发布框架到远程公有库’,其余:
    # 本地库去掉地址即可
    s.source       = { :git => "", :tag => "#{s.version}" }
    
  • 3.验证

    pod lib lint    
    
    出现⚠警告
    localhost:TestLog LouKit$ pod lib lint
    
     -> TestLog (0.0.1)
        - WARN  | homepage: The homepage has not been updated from default
        - WARN  | url: There was a problem validating the URL http://EXAMPLE/TestLog.
        - WARN  | license: Unable to find a license file
    
    [!] TestLog did not pass validation, due to 3 warnings (but you can use `--allow-warnings` to ignore them).
    [!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 
        `echo "2.3" > .swift-version`.
    You can use the `--no-clean` option to inspect any issue.
    警告可接受,无视!
    
  • 4.创建测试工程,并创建Podfile文件,进行安装本地库

    platform :ios, '9.0'
    
    target 'Example' do
    use_frameworks!
    #描述好本地相对路径
    pod 'Test01',:path => '../Lib/Test01'
    
    end
    
  • 5.安装

    pod install 
    

CocoaPods远程私有库使用

  • 1.创建一个专门用于存放spec文件的远程库

  • 2.将远程库地址加入repo

    pod repo add 名字XX 地址
    
  • 3.创建本地模板库

    pod lib create spec文件名称  //记得修改podspec文件
    
  • 4.创建远程库 用于存放 步骤3 存放的库工程

    git add .
    git commit -m 'msg'
    #查看是否有关联远程库,没有需要设置下
    git remote
    //没有设置关联
    git remote add origin 地址
    如:git remote add origin https://git.coding.net/LouKit/xxx.git
    git push origin master  
    
  • 5.验证spec文件

    本地验证 pod lib lint
    远程提交 必须远程验证 pod spec lint (刚刚步骤4提交时没有tag,所以这个步远程验证肯定过不了,需要提交tag)
    
    提交tag:
    git tag 0.1.0
    git push --tags
    //验证
    pod spec lint
    
  • 6.将spec 推送到步骤1的那个私有库

    pod repo push 名字XX spec文件名称.podspec //这里名字XX 必须对应步骤2 那个名字xx
    
  • 7.修改宿主工程podfile

    source 'https://git.coding.net/LouKit/xxx.git'
    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '9.0'
    
    target 'Example' do
        use_frameworks!
    
    pod 'spec文件名称'
    end
    
  • 8.安装

    pod install
    

其他

问题 1. 维护阶段(扩充代码,版本号升级)

需重新提交代码 修改spec描述文件,大概步骤如下:

1. 重新提交代码
    git add .
    git commit -m 'msg'
    git push origin master

2. 打tag 同时改spec描述文件
    git tag 0.2.0
    git push --tags

3. 提交pec文件

4. 更新spec文件到索引库
    pod repo push 名字XX spec文件名称.podspec

问题 2. 依赖关系解决(比如制作库需要依赖AFN)

//直接spec文件描述即可
s.dependency 'AFNetworking', '~> 3.1.0'

问题 3. 依赖关系子库解决
(如一个库里有三个子库,现在只需用到其中一个,不要全部用到 ,即把一个库分成几个小库)

# 代表分离子库
#s.source_files = 'xx/Classes/**/*'  这种写法是匹配所有的

s.subspec 'Category' do |c|
    c.source_files = 'xx/Classes/Category/**/*'
end

s.subspec 'Network' do |n|
    n.source_files = 'xx/Classes/Network/**/*'
    n.dependency 'AFNetworking', '~> 3.1.0'
end

s.subspec 'Tool' do |t|
    t.source_files = 'xx/Classes/Tool/**/*'
end

然后使用这个子库过程podefile 写法
target 'Example' do

   use_frameworks!
    pod 'xx/Category'
    pod 'xx/Network'
end
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Docker是一种流行的容器化技术,可以将应用程序及其依赖项打包成一个独立的容器,方便在不同环境中进行部署和运行。而本地私有则是用于存储和管理这些Docker镜像的地方。下面是关于如何在本地部署私有的步骤: 1. 安装Docker:首先需要在你的机器上安装Docker。你可以根据操作系统的不同,选择合适的安装方式。 2. 创建私有容器:使用以下命令创建一个本地私有容器: ``` docker run -d -p 5000:5000 --restart=always --name registry registry:2 ``` 这个命令会在本地启动一个名为registry的容器,并将其映射到主机的5000端口。 3. 配置Docker客户端:默认情况下,Docker客户端只能从公共仓中拉取镜像。为了能够使用本地私有,需要进行一些配置。在Docker客户端的配置文件(通常是`/etc/docker/daemon.json`)中添加以下内容: ``` { "insecure-registries": ["localhost:5000"] } ``` 这样就允许Docker客户端从本地私有拉取镜像了。 4. 推送和拉取镜像:现在你可以使用`docker push`命令将本地构建的镜像推送到私有中,例如: ``` docker build -t myimage:tag . docker tag myimage:tag localhost:5000/myimage:tag docker push localhost:5000/myimage:tag ``` 同样,你也可以使用`docker pull`命令从私有中拉取镜像: ``` docker pull localhost:5000/myimage:tag ``` 5. 验证私有:你可以通过访问`http://localhost:5000/v2/_catalog`来验证私有是否正常工作。如果返回一个空的JSON对象`{}`,表示私有是空的。 希望以上步骤对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值