Podfile语法参考

Posted by DragonLi on April 7, 2017

Podfile,官方辅助Mac端APP下载

##一:常规使用

  • Podfile文件详细描述了一个或多个工程中targets的依赖关系。Podfile会默认创建一个隐式的目标链接到工程中用户的第一个target,名称为“default”。
  • pod ‘ScreenCompatible_LFL’, ‘~> 1.0.0’
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
inhibit_all_warnings!

xcodeproj 'ProjectName'

pod 'SegmentControlLFL', '~> 1.0.0' 

target :test do
  pod 'Test', '~> 2.0.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    puts #{target.name}
  end
end

##二: Dependencies(依赖项)

  • target 允许你在工程中限定依赖项只在你指定的targets中生效.
  • 版本控制
  • 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,并且始终是你指定范围内的最新版本

  • pod ‘LFL’, ‘1.0’ 具体版本

三:Build configurations(编译配置)

默认情况下, 依赖项会被安装在所有target的build configuration中。为了调试或者处于其他原因,依赖项只能在给定的build configuration中被启用

pod 'name', :configurations => ['Release', 'App Store']

  • Subspecs :pod ‘AFNetWorking/UIkit’

  • 有的时候你可能想要使用一个最新的开发版本,或者某一个二次开发版本。如果是这样,你可以在pod声明中特别标明

 
1.使用仓库中的master分支:
pod 'AFNetworking', :git => 'https://github.com/DevDragonLi/AFNetworking.git'

2.使用仓库的其他分支:
pod 'AFNetworking', :git => 'https://github.com/DevDragonLi/AFNetworking.git', :branch => 'dev'

3.指定一个提交记录:
pod 'AFNetworking', :git => 'https://github.com/DevDragonLi/AFNetworking.git', :commit => '727cdcbhd23'

  • From a podspec outside a spec repository, for a library without podspec(在一个不带podsepec的库里引用外部的spec) ` pod ‘JSONKit’, :podspec => ‘https://example.com/JSONKit.podspec’ `

  • inhibit_all_warnings! 屏蔽cocoapods库里面的所有警告