美文网首页
Podfile常用语法

Podfile常用语法

作者: 瀚_ | 来源:发表于2019-05-23 15:41 被阅读0次
  • 指明索引库
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/Artsy/Specs.git'
  • 屏蔽所有来自于cocoapods依赖库的警告
inhibit_all_warnings!
  • 你可以全局定义,也能在子target里面定义,也可以指定某一个库:
pod 'SSZipArchive', :inhibit_warnings => true
pod 'ShowTVAuth', :inhibit_warnings => false
  • use_frameworks!

通过指定use_frameworks!要求生成的是framework而不是静态库。

如果使用use_frameworks!命令会在Pods工程下的Frameworks目录下生成依赖库的framework

如果不使用use_frameworks!命令会在Pods工程下的Products目录下生成.a的静态库

Dependencies

  1. 如果后面不写依赖库的具体版本号,那么cocoapods会默认选取最新版本。
pod 'SSZipArchive'
  1. 如果你想要特定的依赖库的版本,就需要在后面写上具体版本号,格式:
pod 'Objection', '0.9'
  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版本)的任意一个
    ~> 0.1.2 版本 0.1.2的版本到0.2 ,不包括0.2。这个基于你指定的版本号的最后一个部分。这个例子等效于>= 0.1.2并且 <0.2.0,并且始终是你指定范围内的最新版本。

Build configurations

  • 默认情况下, 依赖项会被安装在所有target的build configuration中。为了调试或者处于其他原因,依赖项只能在给定的build configuration中被启用。
  • 下面写法指明只有在Debug和Beta模式下才有启用配置
pod 'PonyDebugger', :configurations => ['Debug', 'Beta']
  • 或者,可以弄白名单只指定一个build configurations。
pod 'PonyDebugger', :configuration => 'Debug'

Subspecs

  • 仅安装QueryKit库下的Attribute模块
pod 'QueryKit/Attribute'
  • 仅安装QueryKit下的Attribute和QuerySet模块
pod 'QueryKit', :subspecs => ['Attribute', 'QuerySet']
  • 我们也可以指定依赖库的来源地址。如果我们想引入我们本地的一个库,可以这样写
pod 'AFNetworking', :path => '~/Documents/AFNetworking'

指定分支或节点

  • 引入指定的分支
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'

Target

  • target应该与Xcode的target相符。默认情况下,target包含定义在块外的依赖,除非指定不使用inherit!来继承。
  • abstract_target :定义一个抽象的target,为了方便target目标依赖继承。
# 指定当前target是抽象target。
target ‘A’ do
         abstract!
end
  • 设置当前target的继承关系
target 'App’ do
    target ‘A’ do
        #这个target 继承 父级所有行为
        inherit! :complete  
    end
    target ‘B’ do
        #这个target 不继承 父级所有行为
        inherit! :none 
    end
    target ‘C’ do
        #target 仅继承 父级的搜索路劲
        inherit! :search_paths 
    end
end

def命令来声明一个pod集

def 'CustomPods’ 
    pod 'IQKeyboardManagerSwift’ 
end 
#然后,我们就可以在需要引入的target处引入
target 'MyTarget' do CustomPods 
end 

相关文章

  • Podfile常用语法

    指明索引库 屏蔽所有来自于cocoapods依赖库的警告 你可以全局定义,也能在子target里面定义,也可以指定...

  • CocoaPods的Podfile文件编写

    一、Podfile文件? 二、Podfile语法参考 Podfile Syntax Reference官网 1)永...

  • Podfile语法

    1.单个target依赖库 2.多个target依赖库 3.多个target依赖库高端写法 注意: (1) pla...

  • Podfile 语法

    Podfile 是描述一个或多个 Xcode 项目的目标的依赖关系的规范。Podfile文件可以非常简单: 一个更...

  • Podfile语法

    1.单个target依赖库 2.多个target依赖库 3.多个target依赖库高端写法 注意:(1) plat...

  • Podfile语法

    https://guides.cocoapods.org/syntax/podfile.html#podfile[...

  • CocoaPods之Podfile\Podfile.lock

    什么是Podfile ? CocoaPods是用ruby实现的,因此Podfile文件的语法就是ruby的语法。p...

  • CocosPod 语法

    source ‘URL’ : 指定镜像仓库的源 具体的Podfile的语法和用法见文档:Podfile 语法规范P...

  • Podfile语法参考

    1.官方说明:点击这里2.翻译请看简书:这里

  • CocoaPods Podfile 语法

    Podfile 文件 CocoaPods 是通过 Podfile 文件来管理依赖库的,该文件在项目根目录下,如果没...

网友评论

      本文标题:Podfile常用语法

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