Podspec Syntax Reference v1.9.3
1. Root specification
name R
The name of the Pod.
spec.name = 'AFNetworking'
version R
The version of the Pod.
spec.version = '0.0.1'
swift_versions
The versions of Swift that the specification supports. A version of '4' will be treated as '4.0' by CocoaPods and not '4.1' or '4.2'.
spec.swift_versions = ['3.0']
spec.swift_versions = ['3.0', '4.0', '4.2']
spec.swift_version = '3.0'
spec.swift_version = '3.0', '4.0'
cocoapods_version
The version of CocoaPods that the specification supports.
spec.cocoapods_version = '>= 0.36'
authors R
The name and email addresses of the library maintainers, not the Podspec maintainer.
spec.author = 'Darth Vader'
spec.authors = 'Darth Vader', 'Wookiee'
spec.authors = { 'Darth Vader' => 'darthvader@darkside.com',
'Wookiee' => 'wookiee@aggrrttaaggrrt.com' }
social_media_url
The URL for the social media contact of the Pod, CocoaPods web services can use this.
spec.social_media_url = 'https://twitter.com/cocoapods'
spec.social_media_url = 'https://groups.google.com/forum/#!forum/cocoapods'
license R
The license of the Pod.
Unless the source contains a file named LICENSE.* or LICENCE.*, the path of the license file or the integral text of the notice commonly used for the license type must be specified. If a license file is specified, it either must be without a file extensions or be one of txt, md, or markdown.
spec.license = 'MIT'
spec.license = { :type => 'MIT', :file => 'MIT-LICENSE.txt' }
homepage R
The URL of the homepage of the Pod.
spec.homepage = 'http://www.example.com'
source R
The location from where the library should be retrieved 库的检索位置
spec.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git',
:tag => spec.version.to_s }
spec.source = { :svn => 'http://svn.code.sf.net/p/polyclipping/code', :tag => '4.8.8' }
summary R
A short (maximum 140 characters) description of the Pod.
摘要应适当地大写,并包含正确的标点符号
spec.summary = 'Computes the meaning of life.'
description
A description of the Pod more detailed than the summary.
spec.description = <<-DESC
Computes the meaning of life.
Features:
1. Is self aware
...
42. Likes candies.
DESC
screenshots
A list of URLs to images showcasing the Pod. Intended for UI oriented libraries. CocoaPods 推荐使用 Gif 图.
spec.screenshot = 'http://dl.dropbox.com/u/378729/MBProgressHUD/1.png'
spec.screenshots = [ 'http://dl.dropbox.com/u/378729/MBProgressHUD/1.png',
'http://dl.dropbox.com/u/378729/MBProgressHUD/2.png' ]
documentation_url
An optional URL for the documentation of the Pod.
spec.documentation_url = 'http://www.example.com/docs.html'
static_framework
Indicates, that if use_frameworks! is specified, the pod should include a static library framework.(如果use_frameworks!时,pod应该包含一个静态库框架)
spec.static_framework = true
2. File patterns
source_files
The source files of the Pod
spec.source_files = 'Classes/**/*.{h,m}'
spec.source_files = 'Classes/**/*.{h,m}', 'More_Classes/**/*.{h,m}'
exclude_files
A list of file patterns that should be excluded from the other file patterns
不需要导入的文件
spec.ios.exclude_files = 'Classes/osx'
spec.exclude_files = 'Classes/**/unused.{h,m}'
* resources
A list of resources that should be copied into the target bundle.
应该复制到目标包中的资源列表。
For building the Pod as a static library, we strongly recommend library developers to adopt resource bundles as there can be name collisions using the resources attribute. Moreover, resources specified with this attribute are copied directly to the client target and therefore they are not optimised by Xcode.
为了将Pod构建为一个静态库,我们强烈建议库开发人员采用资源包,因为使用resources属性可能会产生名称冲突。此外,使用这个属性指定的资源会直接复制到客户端目标,因此它们不会被Xcode优化。
spec.resource = 'Resources/HockeySDK.bundle'
spec.resources = ['Images/*.png', 'Sounds/*']
* resource_bundles
This attribute allows to define the name and the file of the resource bundles which should be built for the Pod. They are specified as a hash where the keys represent the name of the bundles and the values the file patterns that they should include.
For building the Pod as a static library, we strongly recommend library developers to adopt resource bundles as there can be name collisions using the resources attribute.
The names of the bundles should at least include the name of the Pod to minimise the chance of name collisions.
bundle的名称应该至少包含Pod的名称,以减少名称冲突的可能性。
To provide different resources per platform namespaced bundles must be used.
要为每个平台提供不同的资源,必须使用有名称空间的捆绑包
spec.ios.resource_bundle = { 'MapBox' => 'MapView/Map/Resources/*.png' }
spec.resource_bundles = {
'MapBox' => ['MapView/Map/Resources/*.png'],
'MapBoxOtherResources' => ['MapView/Map/OtherResources/*.png']
}
public_header_files
A list of file patterns that should be used as public headers
应该作为公共头文件使用的文件模式列表
如果没有指定公共头文件,那么source_files中的所有头文件都被认为是公共的。
spec.public_header_files = 'Headers/Public/*.h'
vendored_frameworks
The paths of the framework bundles that come shipped with the Pod.
spec.ios.vendored_frameworks = 'Frameworks/MyFramework.framework'
spec.vendored_frameworks = 'MyFramework.framework', 'TheirFramework.framework'
3. platform
platform
The platform on which this Pod is supported. Leaving this blank means the Pod is supported on all platforms. When supporting multiple platforms you should use deployment_target below instead.
spec.platform = :osx, '10.8'
spec.platform = :ios
spec.platform = :osx
deployment_target
The minimum deployment targets of the supported platforms.
spec.ios.deployment_target = '6.0'
spec.osx.deployment_target = '10.8'
4. Build setting
dependency
Any dependency on other Pods or to a ‘sub-specification’.
spec.dependency 'AFNetworking', '~> 1.0'
spec.dependency 'AFNetworking', '~> 1.0', :configurations => ['Debug']
spec.dependency 'AFNetworking', '~> 1.0', :configurations => :debug
spec.dependency 'RestKit/CoreData', '~> 0.20.0'
spec.ios.dependency 'MBProgressHUD', '~> 0.5'
requires_arc
Allows you to specify which source_files use ARC. This can either be the files which support ARC, or true to indicate all of the source_files use ARC.
spec.requires_arc = true
spec.requires_arc = 'Classes/Arc'
spec.requires_arc = ['Classes/*ARC.m', 'Classes/ARC.mm']
frameworks
A list of system frameworks that the user’s target needs to link against.
spec.ios.framework = 'CFNetwork'
spec.frameworks = 'QuartzCore', 'CoreData'
weak_frameworks
A list of frameworks that the user’s target needs to weakly link against
spec.weak_framework = 'Twitter'
spec.weak_frameworks = 'Twitter', 'SafariServices'
prefix_header_contents
Any content to inject in the prefix header of the pod project.
要注入到pod项目的前缀头中的任何内容
spec.prefix_header_contents = '#import <UIKit/UIKit.h>'
spec.prefix_header_contents = '#import <UIKit/UIKit.h>', '#import <Foundation/Foundation.h>'
prefix_header_file
A path to a prefix header file to inject in the prefix header of the pod project.
要注入到pod项目的前缀头文件的路径
spec.prefix_header_file = 'iphone/include/prefix.pch'
spec.prefix_header_file = false