iOS Cocoapods版本号概念

作者: 一亩三分甜 | 来源:发表于2018-08-13 02:13 被阅读852次

    平常写的pod的版本规范

    • 最常见的版本号:'~>1.0'
    pod 'AFNetworking','~>1.0'
    

    表明版本号为1.0<=x<2.0

    • 指定版本号:'1.0'
    pod 'AFNetworking','1.0'
    

    表明版本号指定为1.0

    • 不指定版本号,任何版本都可以。cocoapods会默认选取最新版本
    pod 'AFNetworking'
    

    版本号详述:

    '> 0.1' Any version higher than 0.1 0.1以上
    '>= 0.1' Version 0.1 and any higher version 0.1以上,包括0.1
    '< 0.1' Any version lower than 0.1 0.1以下
    '<= 0.1' Version 0.1 and any lower version 0.1以下,包括0.1
    '~> 0.1.2' Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher 0.2以下(不含0.2),0.1.2以上(含0.1.2)
    '~> 0.1' Version 0.1 and the versions up to 1.0, not including 1.0 and higher 1.0以下(不含1.0),0.1以上(含0.1)
    '~> 0' Version 0 and higher, this is basically the same as not having it. 0和以上,等于没有此约束
    

    Dependencies依赖项

    依赖项规范是由Pod的名称和一个可选的版本组合一起。

    1.如果后面不写依赖库的具体版本号,那么cocoapods会默认选取最新版本

    pod 'SSZipArchive'
    

    2.如果你想要特定的依赖库的版本,就需要在后面写上具体版本号,格式:

    pod 'SSZipArchive','0.9'
    

    3.也可以指定版本范围

    > 0.1 高于0.1版本(不包含0.1版本)的任意一个版本
    >= 0.1 高于0.1版本(包含0.1版本)的任意一个版本
    < 0.1 低于0.1版本(不包含0.1版本)的任意一个
    <= 0.1低于0.1版本(包含0.1版本)的任意一个
    ~> 0.1.2 版本 0.1.2的版本到0.2 ,不包括0.2。这个基于你指定的版本号的最后一个部分。这个例子等效于>= 0.1.2并且 <0.2.0,并且始终是你指定范围内的最新版本。
    

    有时我们需要引入依赖库指定的分支或节点,写法如下。

    • 引入master分支(默认)
    pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
    
    • 引入指定的分支
    pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
    
    • 引入某个节点的代码
    pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
    
    • 引入某个特殊的提交节点
    pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
    

    相关文章

      网友评论

        本文标题:iOS Cocoapods版本号概念

        本文链接:https://www.haomeiwen.com/subject/cotybftx.html