Podfile里的配置
来源:互联网 发布:嵌入式与单片机的关系 编辑:程序博客网 时间:2024/04/28 01:35
The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects. The Podfile always creates an implicit target, named default
, which links to the first target of the user project. The file should simply be named Podfile
.
A Podfile can be very simple:
pod 'AFNetworking', '~> 2.0'
An example of a more complex Podfile can be:
source 'https://github.com/CocoaPods/Specs.git'source 'https://github.com/Artsy/Specs.git'platform :ios, '8.0'inhibit_all_warnings!xcodeproj 'MyProject'pod 'ObjectiveSugar', '~> 0.5'pod 'Artsy+UILabels', '~> 1.0'target :test do pod 'OCMock', '~> 2.0.1'endpost_install do |installer| installer.pods_project.targets.each do |target| puts target.name endend
If you want multiple targets, like adding tests, to share the same pods.
platform :osx, '10.7'link_with 'MyApp', 'MyApp Tests'pod 'AFNetworking', '~> 2.0'pod 'Objection', '0.9'
<Specifying pod versions
When starting out with a project it is likely that you will want to use the latest version of a Pod. If this is the case, simply omit the version requirements.
pod 'SSZipArchive'
Later on in the project you may want to freeze to a specific version of a Pod, in which case you can specify that version number.
pod 'Objection', '0.9'
Besides no version, or a specific one, it is also possible to use logical operators:
'> 0.1'
Any version higher than 0.1'>= 0.1'
Version 0.1 and any higher version'< 0.1'
Any version lower than 0.1'<= 0.1'
Version 0.1 and any lower version
In addition to the logic operators CocoaPods has an optimistic operator ~>
:
'~> 0.1.2'
Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher'~> 0.1'
Version 0.1 and the versions up to 1.0, not including 1.0 and higher'~> 0'
Version 0 and higher, this is basically the same as not having it.
For more information, regarding versioning policy, see:
- Semantic Versioning
- RubyGems Versioning Policies
Finally, instead of a version, you can specify the :head
flag. This will use the pod’s latest version spec version, but force the download of the ‘bleeding edge’ version. Use this with caution, as the spec might not be compatible with the source material anymore.
pod 'Objection', :head
<Version Conflicts
Pods often depend on other pods. Conflicts arise when multiple pods depend on different versions of another. Or you may want to tie a dependent pod to a particular version.
The conflict error looks like this:
[!] Podfile tries to activate `GoogleAnalytics-iOS-SDK (= 2.0beta4)', but already activated version `3.0' by ARAnalytics/GoogleAnalytics (1.6).
To fix this, you simply add the
GoogleAnalytics-iOS-SDK
pod line beforeARAnalytics
and specify the version:
pod 'GoogleAnalytics-iOS-SDK', '2.0beta4'pod 'ARAnalytics/GoogleAnalytics'
<Using the files from a folder local to the machine.
If you would like to develop a Pod in tandem with its client project you can use
:path
.
pod 'AFNetworking', :path => '~/Documents/AFNetworking'
Using this option CocoaPods will assume the given folder to be the root of the Pod and will link the files directly from there in the Pods project. This means that your edits will persist between CocoaPods installations. The referenced folder can be a checkout of your favourite SCM or even a Git submodule of the current repo.
Note that thepodspec
of the Pod file is expected to be in that folder.<From a podspec in the root of a library repo.
Sometimes you may want to use the bleeding edge version of a Pod, a specific revision or your own fork. If this is the case, you can specify that with your pod declaration.
To use the
master
branch of the repo:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
To use a different branch of the repo:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
To use a tag of the repo:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
Or specify a commit:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
It is important to note, though, that this means that the version will have to satisfy any other dependencies on the Pod by other Pods.
The podspec
file is expected to be in the root of the repo, if this library does not have a podspec
file in its repo yet, you will have to use one of the approaches outlined in the sections below.
- Podfile里的配置
- Podfile的详细配置
- cocopods里的Podfile相关内容
- cocopods里的Podfile相关内容
- 多个Target的podfile文件配置
- Cocoapods Podfile配置
- 使用CocoaPods下载第三方库时的Podfile配置问题
- Podfile的简单使用
- 新的 podfile 写法
- cocoapods升级到1.0.1后,podfile文件里的变更
- podfile
- Podfile
- podfile
- Podfile
- Cocoapods配置文件Podfile的编写
- CocoaPods 的Podfile Syntax Reference
- cocaopods升级及配置Podfile文件
- Hibernate里的配置
- sqlmap的应用实战
- Java设计模式
- LLDB的简单使用
- bootstrapValidator插件动态添加和移除校验
- JPAd的应用
- Podfile里的配置
- 导出table列表数据到excel(第5种方法适用多个浏览器)
- centos下pip安装mysql_python
- Junit4:测试方法执行顺序
- Java并发编程:并发容器之ConcurrentHashMap
- Vs2010连接Mysql数据库方法
- 多例模式【Multition Pattern】
- Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
- js中闭包的使用