Podfile

作者: 峰远 | 来源:发表于2016-12-14 11:58 被阅读0次

Podfile

Version 1.0

project "/Users/lishucheng/Desktop/day/day.xcodeproj"
source 'https://github.com/CocoaPods/Specs.git'

platform:ios,'7.0'
inhibit_all_warnings!
targetsArray = ['day', 'day2']
targetsArray.each do |item|
    target item do
        pod 'AFNetworking'
    end
end

参数

pod 'AFNetworking'                  //每次都获取最新版本  
pod 'AFNetworking', '2.0'           //只使用2.0版本  
pod 'AFNetworking', '> 2.0'         //使用高于2.0的版本  
pod 'AFNetworking', '>= 2.0'        //使用大于或等于2.0的版本  
pod 'AFNetworking', '< 2.0'         //使用小于2.0的版本  
pod 'AFNetworking', '<= 2.0'        //使用小于或等于2.0的版本  
pod 'AFNetworking', '~> 0.1.2'      //使用大于等于0.1.2但小于0.2的版本  
pod 'AFNetworking', '~>0.1'         //使用大于等于0.1但小于1.0的版本  
pod 'AFNetworking', '~>0'           //高于0的版本,和什么都不写一个效果,表示使用最新版本  

一般Podfile放在工程的根目录下,如果不放在根目录下,需要使用project指定工程的路径

project "/Users/lishucheng/Desktop/day/day.xcodeproj"

如果project中有多个target(link_with已不能用)

target 'day' do
pod 'AFNetworking'
end

target 'day2' do
pod 'AFNetworking'
end

如果target太多,因为cocoapods是ruby写的,所以可以使用rub语法

targetsArray = ['day', 'day2']
targetsArray.each do |item|
    target item do
        pod 'AFNetworking'
    end
end

命令

pod install    //根据Podfile文件安装依赖库,如果有Podfile.lock文件而且对应的Podfile文件未被修改,则会根据Podfile.lock文件指定的版本安装
pod update     //如果Podfile中指定的依赖库版本不是写死的,当对应的依赖库有了更新,无论有没有Podfile.lock文件都会去获取Podfile文件描述的允许获取到的最新依赖库版本。
pod search AFNetworking  //搜索
pod setup //跟新本地电脑上的保存的Pods依赖库tree

如果pod install或者pod update慢(执行以上两个命令的时候会升级CocoaPods的spec仓库)可以使用一下命令

pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

或者

pod install --no-repo-update
pod update --no-repo-update

Podfile.lock

保存已经安装的Pods依赖库的版本,多人开发时,使其他人check后执行pod install后,Pods版本和其他人一致。

相关文章

  • pod命令行操作

    首先:cd 项目touch Podfile一个文件vim Podfile进入Podfile文件在Podfile文件...

  • (四)Podfile vs. Podfile.lock

    下面是 Podfile 与 Podfile.lock 两个文件的对比: Podfile: Podfile.lock:

  • cocoapods 使用

    1 cd 空格 路径 2 touch Podfile 编辑 Podfile文件 1)输入 vim Podfile,...

  • CocoaPods的Podfile文件编写

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

  • git 代码合并冲突

    Auto-merging Podfile.lock podfile.lock合并冲突 podfile.lock 该...

  • Flutter 项目升级报错处理

    1、flutter Warning: Podfile is out of dateWarning: Podfile...

  • Pod 新建项目

    1,打开命令行 cd 你的项目目录 2,新建Podfile touch Podfile 3, 编辑Podfile ...

  • cocoapods-prefer解析

    hook cocoapods的类 podfile 在podfile.rb文件实现在podfile调用的函数,传递参...

  • Podfile 库版本运算符

    一个简单的podfile: 一个更简单的podfile: 一个更更简单的podfile: 一个复杂的podfile...

  • Podfile

    什么是 Podfile Podfile是一个规范,用于描述一个或多个Xcode项目的目标依赖关系。 该文件应该简单...

网友评论

      本文标题:Podfile

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