Module: Pod::Specification::DSL

Extended by:
AttributeSupport
Included in:
Pod::Specification
Defined in:
lib/cocoapods-core/specification/dsl.rb,
lib/cocoapods-core/specification/dsl/attribute.rb,
lib/cocoapods-core/specification/dsl/deprecations.rb,
lib/cocoapods-core/specification/dsl/platform_proxy.rb,
lib/cocoapods-core/specification/dsl/attribute_support.rb,
lib/cocoapods-core/specification/root_attribute_accessors.rb

Overview

A specification describes a version of Pod library. It includes details about where the source should be fetched from, what files to use, the build settings to apply, and other general metadata such as its name, version, and description.


A stub specification file can be generated by the [pod spec create](guides.cocoapods.org/terminal/commands.html#pod_spec_create) command.


The specification DSL provides great flexibility and dynamism. Moreover, the DSL adopts the [convention over configuration](en.wikipedia.org/wiki/Convention_over_configuration) and thus it can be very simple:

Pod::Spec.new do |spec|
  spec.name         = 'Reachability'
  spec.version      = '3.1.0'
  spec.license      = { :type => 'BSD' }
  spec.homepage     = 'https://github.com/tonymillion/Reachability'
  spec.authors      = { 'Tony Million' => '[email protected]' }
  spec.summary      = 'ARC and GCD Compatible Reachability Class for iOS and OS X.'
  spec.source       = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
  spec.source_files = 'Reachability.{h,m}'
  spec.framework    = 'SystemConfiguration'
end

Defined Under Namespace

Modules: AttributeSupport, Deprecations, RootAttributesAccessors Classes: Attribute, PlatformProxy

Root specification A ‘root’ specification stores the information about the specific version of a library. The attributes in this group can only be written to on the ‘root’ specification, **not** on the ‘sub-specifications’. --- The attributes listed in this group are the only one which are required by a podspec. The attributes of the other groups are offered to refine the podspec and follow a convention over configuration approach. A root specification can describe these attributes either directly of through ‘[sub-specifications](#subspec)’. collapse

LICENSE_KEYS =

The keys accepted by the license attribute.

[:type, :file, :text].freeze
SOURCE_KEYS =

The keys accepted by the hash of the source attribute.

{
  :git  => [:tag, :branch, :commit, :submodules].freeze,
  :svn  => [:folder, :tag, :revision].freeze,
  :hg   => [:revision].freeze,
  :http => [:flatten, :type, :sha256, :sha1].freeze,
  :path => nil,
}.freeze

Platform A specification should indicate the platforms and the correspondent deployment targets on which the library is supported. If not defined in a subspec the attributes of this group inherit the value of the parent. collapse

PLATFORMS =

The names of the platforms supported by the specification class.

[:osx, :ios, :tvos, :watchos].freeze

Class Attribute Summary collapse

Root specification A ‘root’ specification stores the information about the specific version of a library. The attributes in this group can only be written to on the ‘root’ specification, **not** on the ‘sub-specifications’. --- The attributes listed in this group are the only one which are required by a podspec. The attributes of the other groups are offered to refine the podspec and follow a convention over configuration approach. A root specification can describe these attributes either directly of through ‘[sub-specifications](#subspec)’. collapse

Platform A specification should indicate the platforms and the correspondent deployment targets on which the library is supported. If not defined in a subspec the attributes of this group inherit the value of the parent. collapse

Build settings In this group are listed the attributes related to the configuration of the build environment that should be used to build the library. If not defined in a subspec the attributes of this group inherit the value of the parent. collapse

File patterns Podspecs should be located at the **root** of the repository, and paths to files should be specified **relative** to the root of the repository as well. File patterns do not support traversing the parent directory ( `..` ). File patterns may contain the following wildcard patterns: --- ### Pattern: * Matches any file. Can be restricted by other values in the glob. * `*` will match all files * `c*` will match all files beginning with `c` * `*c` will match all files ending with `c` * `*c*` will match all files that have `c` in them (including at the beginning or end) Equivalent to `/.*/x` in regexp. **Note** this will not match Unix-like hidden files (dotfiles). In order to include those in the match results, you must use something like `{*,.*}`. --- ### Pattern: ** Matches directories recursively. --- ### Pattern: ? Matches any one character. Equivalent to `/.{1}/` in regexp. --- ### Pattern: [set] Matches any one character in set. Behaves exactly like character sets in Regexp, including set negation (`[^a-z]`). --- ### Pattern: {p,q} Matches either literal `p` or literal `q`. Matching literals may be more than one character in length. More than two literals may be specified. Equivalent to pattern alternation in regexp. --- ### Pattern: \ Escapes the next meta-character. --- ### Examples Consider these to be evaluated in the source root of [JSONKit](https://github.com/johnezang/JSONKit). "JSONKit.?" #=> ["JSONKit.h", "JSONKit.m"] "*.[a-z][a-z]" #=> ["CHANGELOG.md", "README.md"] "*.[^m]*" #=> ["JSONKit.h"] "*.{h,m}" #=> ["JSONKit.h", "JSONKit.m"] "*" #=> ["CHANGELOG.md", "JSONKit.h", "JSONKit.m", "README.md"] collapse

Subspecs A library can specify a dependency on either another library, a subspec of another library, or a subspec of itself. collapse

Multi-Platform support A specification can store values which are specific to only one platform. --- For example one might want to store resources which are specific to only iOS projects. spec.resources = "Resources/**/*.png" spec.ios.resources = "Resources_ios/**/*.png" collapse

Methods included from AttributeSupport

attribute, root_attribute

Class Attribute Details

.attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/cocoapods-core/specification/dsl/attribute_support.rb', line 7

def attributes
  @attributes
end

Instance Method Details

#authors=(authors) ⇒ Object

The name and email addresses of the library maintainers, not the Podspec maintainer.

Examples:


spec.author = 'Darth Vader'

spec.authors = 'Darth Vader', 'Wookiee'

spec.authors = { 'Darth Vader' => '[email protected]',
                 'Wookiee'     => '[email protected]' }

Parameters:

  • authors (String, Hash{String=>String})

    the list of the authors of the library and their emails.



142
143
144
145
146
# File 'lib/cocoapods-core/specification/dsl.rb', line 142

root_attribute :authors,
:types       => [String, Array, Hash],
:container   => Hash,
:required    => true,
:singularize => true

#cocoapods_version=(cocoapods_version) ⇒ Object

The version of CocoaPods that the sepcification supports.



117
# File 'lib/cocoapods-core/specification/dsl.rb', line 117

root_attribute :cocoapods_version

#compiler_flags=(flags) ⇒ Object

A list of flags which should be passed to the compiler.

Examples:


spec.compiler_flags = '-DOS_OBJECT_USE_OBJC=0', '-Wno-format'

Parameters:

  • flags (String, Array<String>)

    A list of flags.



763
764
765
766
# File 'lib/cocoapods-core/specification/dsl.rb', line 763

attribute :compiler_flags,
:container   => Array,
:singularize => true,
:inherited => true

#default_subspecs=(subspec_array) ⇒ Object

An array of subspecs names that should be used as preferred dependency. If not specified a specifications requires all its subspecs as dependencies.


A Pod should make available the full library by default. Users can fine tune their dependencies, and exclude unneeded subspecs, once their requirements are known. Therefore, this attribute is rarely needed. It is intended to be used to select a default if there are ‘sub-specifications’ which provide alternative incompatible implementations, or to exclude modules rarely needed (especially if they trigger dependencies on other libraries).

Examples:


spec.default_subspec = 'Core'
spec.default_subspecs = 'Core', 'UI'

Parameters:

  • subspec_names (Array<String>)

    An array of subspec names that should be inherited as dependency.



1361
1362
1363
1364
# File 'lib/cocoapods-core/specification/dsl.rb', line 1361

attribute :default_subspecs,
:container => Array,
:singularize => true,
:multi_platform => false

#dependency(*args) ⇒ Object

Any dependency on other Pods or to a ‘sub-specification’.


Dependencies can specify versions requirements. The use of the optimistic version indicator ‘~>` is recommended because it provides good control over the version without being too restrictive. For example, `~> 1.0.1` is equivalent to `>= 1.0.1` combined with `< 1.1`. Similarly, `~> 1.0` will match `1.0`, `1.0.1`, `1.1`, but will not upgrade to `2.0`.

Pods with overly restrictive dependencies limit their compatibility with other Pods.

Examples:

spec.dependency 'AFNetworking', '~> 1.0'
spec.dependency 'RestKit/CoreData', '~> 0.20.0'
spec.ios.dependency 'MBProgressHUD', '~> 0.5'


626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# File 'lib/cocoapods-core/specification/dsl.rb', line 626

def dependency(*args)
  name, *version_requirements = args
  if name == self.name
    raise Informative, "A specification can't require itself as a " \
      'subspec'
  end
  if @parent
    composed_name = ''
    @parent.name.split('/').each do |component|
      composed_name << component
      if name == composed_name
        raise Informative, "A subspec can't require one of its " \
          'parents specifications'
      else
        composed_name << '/'
      end
    end
  end
  unless version_requirements.all? { |req| req.is_a?(String) }
    raise Informative, 'Unsupported version requirements'
  end
  attributes_hash['dependencies'] ||= {}
  attributes_hash['dependencies'][name] = version_requirements
end

#deployment_target=(*_args) ⇒ Object

The minimum deployment targets of the supported platforms.


The following behavior is regarding the use of GCD and the ‘OS_OBJECT_USE_OBJC` flag. When set to `0`, it will allow code to use `dispatch_release()` on >= iOS 6.0 and OS X >= 10.8.

  • New libraries that do not require ARC don’t need to care about this issue at all.

  • New libraries that do require ARC and have a deployment target of >= iOS 6.0 or OS X >= 10.8:

    These *no longer* use ‘dispatch_release()` and should have the `OS_OBJECT_USE_OBJC` flag set to `1`.

    Note: this means that these libraries have to specify the

    deployment target in their specifications in order to have
    CocoaPods set the flag to `1` and ensure proper behaviour.
    
  • New libraries that do require ARC, but have a deployment target of < iOS 6.0 or OS X < 10.8:

    These contain ‘dispatch_release()` calls and as such need the `OS_OBJECT_USE_OBJC` flag set to `0`.

    Note: libraries that do not specify a platform version are

    assumed to have a deployment target of < iOS 6.0 or OS X < 10.8.
    
For more information, see: http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h

Examples:


spec.ios.deployment_target = "6.0"

spec.osx.deployment_target = "10.8"

Parameters:

  • _args (String)

    The deployment target of the platform.

Raises:



581
582
583
584
# File 'lib/cocoapods-core/specification/dsl.rb', line 581

def deployment_target=(*_args)
  raise Informative, 'The deployment target can be declared only per ' \
    'platform.'
end

#deprecated=(flag) ⇒ Object

Whether the library has been deprecated.

Examples:


spec.deprecated = true

Parameters:

  • flag (Bool)

    whether the library has been deprecated.



464
465
466
# File 'lib/cocoapods-core/specification/dsl.rb', line 464

root_attribute :deprecated,
:types => [TrueClass, FalseClass],
:default_value => false

#deprecated_in_favor_of=(deprecated_in_favor_of) ⇒ Object

The name of the Pod that this one has been deprecated in favor of.

Examples:


spec.deprecated_in_favor_of = 'NewMoreAwesomePod'

Parameters:

  • deprecated_in_favor_of (String)

    the name of the Pod that this one has been deprecated in favor of.



480
# File 'lib/cocoapods-core/specification/dsl.rb', line 480

root_attribute :deprecated_in_favor_of

#description=(description) ⇒ Object

A description of the Pod more detailed than the summary.

Examples:


spec.description = <<-DESC
                     Computes the meaning of life.
                     Features:
                     1. Is self aware
                     ...
                     42. Likes candies.
                   DESC

Parameters:

  • description (String)

    A longer description of the Pod.



377
# File 'lib/cocoapods-core/specification/dsl.rb', line 377

root_attribute :description

#docset_url=(docset_url) ⇒ Object

The URL for the docset for the Pod

Examples:


spec.docset_url = 'http://example.org/KFData/1.0.0/xcode-docset.atom'

Parameters:

  • docset_url (String)

    the docset URL.



184
# File 'lib/cocoapods-core/specification/dsl.rb', line 184

root_attribute :docset_url

#documentation_url=(documentation_url) ⇒ Object

An optional URL for the documentation of the Pod which will be honoured by CocoaPods web properties. Leaving it blank will default to a CocoaDocs generated URL for your library.

Examples:


spec.documentation_url = 'http://www.example.com/docs.html'

Parameters:

  • documentation_url (String)

    The link of the web documentation of the Pod.



417
# File 'lib/cocoapods-core/specification/dsl.rb', line 417

root_attribute :documentation_url

#exclude_files=(exclude_files) ⇒ Object

A list of file patterns that should be excluded from the other file patterns.

Examples:


spec.ios.exclude_files = "Classes/osx"

spec.exclude_files = "Classes/**/unused.{h,m}"

Parameters:

  • exclude_files (String, Array<String>)

    the file patterns that the Pod should ignore.



1197
1198
1199
# File 'lib/cocoapods-core/specification/dsl.rb', line 1197

attribute :exclude_files,
:container     => Array,
:file_patterns => true

#frameworks=(*frameworks) ⇒ Object

A list of system frameworks that the user’s target needs to link against.

Examples:


spec.ios.framework = 'CFNetwork'

spec.frameworks = 'QuartzCore', 'CoreData'

Parameters:

  • frameworks (String, Array<String>)

    A list of framework names.



703
704
705
706
# File 'lib/cocoapods-core/specification/dsl.rb', line 703

attribute :frameworks,
:container   => Array,
:singularize => true,
:inherited => true

#header_dir=(dir) ⇒ Object

The directory where to store the headers files so they don’t break includes.

Examples:


spec.header_dir = 'Three20Core'

Parameters:

  • dir (String)

    the headers directory.



900
901
# File 'lib/cocoapods-core/specification/dsl.rb', line 900

attribute :header_dir,
:inherited => true

#header_mappings_dir=(dir) ⇒ Object

A directory from where to preserve the folder structure for the headers files. If not provided the headers files are flattened.

Examples:


spec.header_mappings_dir = 'src/include'

Parameters:

  • dir (String)

    the directory from where to preserve the headers namespacing.



917
918
# File 'lib/cocoapods-core/specification/dsl.rb', line 917

attribute :header_mappings_dir,
:inherited => true

#homepage=(homepage) ⇒ Object

The URL of the homepage of the Pod.

Examples:


spec.homepage = 'http://www.example.com'

Parameters:

  • homepage (String)

    the URL of the homepage of the Pod.



251
252
# File 'lib/cocoapods-core/specification/dsl.rb', line 251

root_attribute :homepage,
:required => true

#iosPlatformProxy

Provides support for specifying iOS attributes.

Examples:

spec.ios.source_files = "Classes/ios/**/*.{h,m}"

Returns:



1390
1391
1392
# File 'lib/cocoapods-core/specification/dsl.rb', line 1390

def ios
  PlatformProxy.new(self, :ios)
end

#libraries=(*libraries) ⇒ Object

A list of system libraries that the user’s target (application) needs to link against.

Examples:


spec.ios.library = 'xml2'

spec.libraries = 'xml2', 'z'

Parameters:

  • libraries (String, Array<String>)

    A list of library names.



745
746
747
748
# File 'lib/cocoapods-core/specification/dsl.rb', line 745

attribute :libraries,
:container   => Array,
:singularize => true,
:inherited => true

#license=(license) ⇒ Object

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`.

This information is used by CocoaPods to generate acknowledgement files (markdown and plist) which can be used in the acknowledgements section of the final application.

Examples:


spec.license = 'MIT'

spec.license = { :type => 'MIT', :file => 'MIT-LICENSE.txt' }

spec.license = { :type => 'MIT', :text => <<-LICENSE
                   Copyright 2012
                   Permission is granted to...
                 LICENSE
               }

Parameters:

  • license (String, Hash{Symbol=>String})

Options Hash (license):

  • :type (String)

    license type

  • :file (String)

    file containing full license text. Supports txt, md, and markdown

  • :text (String)

    full license text

Parameters:

  • license (String)

    The type of the license



233
234
235
236
# File 'lib/cocoapods-core/specification/dsl.rb', line 233

root_attribute :license,
:container => Hash,
:keys      => LICENSE_KEYS,
:required  => true

#module_map=(module_map) ⇒ Object

The module map file that should be used when this pod is integrated as a framework.


By default, CocoaPods creates a module map file based upon the public headers in a specification.

Examples:


spec.module_map = "source/module.modulemap"

Parameters:

  • module_map (String)

    the path to the module map file that should be used.



1247
1248
# File 'lib/cocoapods-core/specification/dsl.rb', line 1247

attribute :module_map,
:root_only     => true

#module_name=(name) ⇒ Object

The name to use for the framework / clang module which will be generated for this specification instead of the default (header_dir if set, otherwise the specification name).

Examples:


spec.module_name = 'Three20'

Parameters:

  • name (String)

    the module name.



884
# File 'lib/cocoapods-core/specification/dsl.rb', line 884

root_attribute :module_name

#name=(name) ⇒ Object

The name of the Pod.

Examples:


spec.name = 'AFNetworking'

Parameters:

  • name (String)

    the name of the pod.



81
82
83
84
# File 'lib/cocoapods-core/specification/dsl.rb', line 81

attribute :name,
:required => true,
:inherited => false,
:multi_platform => false

#osxPlatformProxy

Provides support for specifying OS X attributes.

Examples:

spec.osx.source_files = "Classes/osx/**/*.{h,m}"

Returns:



1401
1402
1403
# File 'lib/cocoapods-core/specification/dsl.rb', line 1401

def osx
  PlatformProxy.new(self, :osx)
end

#platform=(args) ⇒ Object

The platform on which this Pod is supported. Leaving this blank means the Pod is supported on all platforms.

Examples:


spec.platform = :osx, "10.8"

spec.platform = :ios

spec.platform = :osx

Parameters:

  • args (Array<Symbol, String>)

    A tuple where the first value is the name of the platform, (either ‘:ios` or `:osx`) and the second is the deployment target.



526
527
528
529
530
531
532
533
# File 'lib/cocoapods-core/specification/dsl.rb', line 526

def platform=(args)
  name, deployment_target = args
  if name
    attributes_hash['platforms'] = { name.to_s => deployment_target }
  else
    attributes_hash['platforms'] = {}
  end
end

#pod_target_xcconfig=(value) ⇒ Object

Any flag to add to the final __private__ pod target xcconfig file.

Examples:


spec.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-lObjC' }

Parameters:

  • value (Hash{String => String})

    Key-value pairs representing build settings.



781
782
783
# File 'lib/cocoapods-core/specification/dsl.rb', line 781

attribute :pod_target_xcconfig,
:container => Hash,
:inherited => true

#prefix_header_contents=(content) ⇒ Object

Any content to inject in the prefix header of the pod project.


This attribute is __not recommended__ as Pods should not pollute the prefix header of other libraries or of the user project.

Examples:


spec.prefix_header_contents = '#import <UIKit/UIKit.h>'

spec.prefix_header_contents = '#import <UIKit/UIKit.h>', '#import <Foundation/Foundation.h>'

Parameters:

  • content (String)

    The contents of the prefix header.



842
843
844
# File 'lib/cocoapods-core/specification/dsl.rb', line 842

attribute :prefix_header_contents,
:types => [Array, String],
:inherited => true

#prefix_header_file=(path) ⇒ Object

A path to a prefix header file to inject in the prefix header of the pod project.


This attribute is __not recommended__ as Pods should not pollute the prefix header of other libraries or of the user project.

Examples:


spec.prefix_header_file = 'iphone/include/prefix.pch'

Parameters:

  • path (String)

    The path to the prefix header file.



865
866
# File 'lib/cocoapods-core/specification/dsl.rb', line 865

attribute :prefix_header_file,
:inherited => true

#prepare_command=(command) ⇒ Object

A bash script that will be executed after the Pod is downloaded. This command can be used to create, delete and modify any file downloaded and will be ran before any paths for other file attributes of the specification are collected.

This command is executed before the Pod is cleaned and before the Pods project is created. The working directory is the root of the Pod.

If the pod is installed with the ‘:path` option this command will not be executed.

Examples:


spec.prepare_command = 'ruby build_files.rb'

spec.prepare_command = <<-CMD
                        sed -i 's/MyNameSpacedHeader/Header/g' ./**/*.h
                        sed -i 's/MyNameOtherSpacedHeader/OtherHeader/g' ./**/*.h
                   CMD

Parameters:

  • command (String)

    the prepare command of the pod.



449
# File 'lib/cocoapods-core/specification/dsl.rb', line 449

root_attribute :prepare_command

#preserve_paths=(preserve_paths) ⇒ Object

Any file that should not be removed after being downloaded.


By default, CocoaPods removes all files that are not matched by any of the other file pattern.

Examples:


spec.preserve_path = "IMPORTANT.txt"

spec.preserve_paths = "Frameworks/*.framework"

Parameters:

  • preserve_paths (String, Array<String>)

    the paths that should be not cleaned.



1223
1224
1225
1226
# File 'lib/cocoapods-core/specification/dsl.rb', line 1223

attribute :preserve_paths,
:container     => Array,
:file_patterns => true,
:singularize   => true

#private_header_files=(private_header_files) ⇒ Object

A list of file patterns that should be used to mark private headers.


These patterns are matched against the public headers (or all the headers if no public headers have been specified) to exclude those headers which should not be exposed to the user project and which should not be used to generate the documentation.

Examples:


spec.private_header_files = "Headers/Private/*.h"

Parameters:

  • private_header_files (String, Array<String>)

    the private headers of the Pod.



1062
1063
1064
# File 'lib/cocoapods-core/specification/dsl.rb', line 1062

attribute :private_header_files,
:container => Array,
:file_patterns => true

#public_header_files=(public_header_files) ⇒ Object

A list of file patterns that should be used as public headers.


These are the headers that will be exposed to the user’s project and from which documentation will be generated. If no public headers are specified then all the headers in source_files are considered public.

Examples:


spec.public_header_files = "Headers/Public/*.h"

Parameters:

  • public_header_files (String, Array<String>)

    the public headers of the Pod.



1038
1039
1040
# File 'lib/cocoapods-core/specification/dsl.rb', line 1038

attribute :public_header_files,
:container => Array,
:file_patterns => true

#requires_arc=(flag) ⇒ Object

‘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.

Files which do not use ARC will have the ‘-fno-objc-arc` compiler flag.

The default value of this attribute is ‘true`.

Examples:


spec.requires_arc = false

spec.requires_arc = 'Classes/Arc'

spec.requires_arc = ['Classes/*ARC.m', 'Classes/ARC.mm']

Parameters:

  • flag (Bool, String, Array<String>)

    whether the source files require ARC.



679
680
681
682
683
# File 'lib/cocoapods-core/specification/dsl.rb', line 679

attribute :requires_arc,
:types => [TrueClass, FalseClass, String, Array],
:file_patterns => true,
:default_value => true,
:inherited => true

#resource_bundles=(*frameworks) ⇒ Object

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.

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.

To provide different resources per platform namespaced bundles must be used.

Examples:


spec.ios.resource_bundle = { 'MapBox' => 'MapView/Map/Resources/*.png' }

spec.resource_bundles = {
    'MapBox' => ['MapView/Map/Resources/*.png'],
    'OtherResources' => ['MapView/Map/OtherResources/*.png']
  }

Parameters:

  • resource_bundles (Hash{String=>String})

    A hash where the keys are the names of the resource bundles and the values are their relative file patterns.



1144
1145
1146
1147
1148
# File 'lib/cocoapods-core/specification/dsl.rb', line 1144

attribute :resource_bundles,
:types => [String, Array],
:container => Hash,
:file_patterns => true,
:singularize => true

#resources=(resources) ⇒ Object

A list of resources that should be copied into the target bundle.

We strongly recommend library developers to adopt [resource bundles](guides.cocoapods.org/syntax/podspec.html#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.

Examples:


spec.resource = "Resources/HockeySDK.bundle"

spec.resources = ["Images/*.png", "Sounds/*"]

Parameters:

  • resources (String, Array<String>)

    The resources shipped with the Pod.



1174
1175
1176
1177
# File 'lib/cocoapods-core/specification/dsl.rb', line 1174

attribute :resources,
:container     => Array,
:file_patterns => true,
:singularize   => true

#screenshots=(screenshots) ⇒ Object

A list of URLs to images showcasing the Pod. Intended for UI oriented libraries. CocoaPods recommends the usage of the ‘gif` format.

Examples:


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" ]

Parameters:

  • screenshots (String)

    An URL for the screenshot of the Pod.



398
399
400
# File 'lib/cocoapods-core/specification/dsl.rb', line 398

root_attribute :screenshots,
:singularize    => true,
:container      => Array

#social_media_url=(social_media_url) ⇒ Object

The URL for the social media contact of the Pod, CocoaPods web services can use this.

For example, the @CocoaPodsFeed notifications will include the Twitter handle (shortening the description) if the URL is relative to Twitter. This does not necessarily have to be a Twitter URL, but only those are included in the Twitter @CocoaPodsFeed notifications.

Examples:


spec.social_media_url = 'https://twitter.com/cocoapods'

spec.social_media_url = 'https://groups.google.com/forum/#!forum/cocoapods'

Parameters:

  • social_media_url (String)

    the social media URL.



171
# File 'lib/cocoapods-core/specification/dsl.rb', line 171

root_attribute :social_media_url

#source=(git) ⇒ Object #source=(svn) ⇒ Object #source=(hg) ⇒ Object #source=(http) ⇒ Object #source=(path) ⇒ Object

The location from where the library should be retrieved.

Examples:

Specifying a Git source with a tag. This is how most OSS Podspecs work.


spec.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git',
                :tag => spec.version.to_s }

Using a tag prefixed with ‘v’ and submodules.


spec.source = { :git => 'https://github.com/typhoon-framework/Typhoon.git',
                :tag => "v#{spec.version}", :submodules => true }

Using Subversion with a tag.


spec.source = { :svn => "http://svn.code.sf.net/p/polyclipping/code", :tag => '4.8.8' }

Using Mercurial with the same revision as the spec’s semantic version string.


spec.source = { :hg => "https://bitbucket.org/dcutting/hyperbek", :revision => "#{s.version}" }

Using HTTP to download a compressed file of the code. It supports zip, tgz, bz2, txz and tar.


spec.source = { :http => "http://dev.wechatapp.com/download/sdk/WeChat_SDK_iOS_en.zip" }

Using HTTP to download a file using a hash to verify the download. It supports sha1 and sha256.


spec.source = { :http => 'http://dev.wechatapp.com/download/sdk/WeChat_SDK_iOS_en.zip',
                :sha1 => '7e21857fe11a511f472cfd7cfa2d979bd7ab7d96' }

Overloads:

  • #source=(git) ⇒ Object

    Parameters:

    • git (Hash)

    Options Hash (git):

    • :git (String)

      git source URI

    • :tag (String)

      version tag

    • :submodules (Bool)

      Whether to checkout submodules

    • :branch (String)

      branch name

    • :commit (String)

      commit hash

  • #source=(svn) ⇒ Object

    Parameters:

    • svn (Hash)

    Options Hash (svn):

    • :svn (String)

      svn source URI

    • :tag (String)

      version tag

    • :folder (String)

      folder

    • :revision (String)

      revision

  • #source=(hg) ⇒ Object

    Parameters:

    • hg (Hash)

    Options Hash (hg):

    • :hg (String)

      mercurial source URI

    • :revision (String)

      revision

  • #source=(http) ⇒ Object

    Parameters:

    • http (Hash)

    Options Hash (http):

    • :http (String)

      compressed source URL

    • :type (String)

      file type. Supports zip, tgz, bz2, txz and tar

    • :sha1 (String)

      SHA hash. Supports SHA1 and SHA256

  • #source=(path) ⇒ Object

    Parameters:

    • path (Hash)

    Options Hash (path):

    • :path (String)

      local source path



328
329
330
331
# File 'lib/cocoapods-core/specification/dsl.rb', line 328

root_attribute :source,
:container => Hash,
:keys      => SOURCE_KEYS,
:required  => true

#source_files=(source_files) ⇒ Object

The source files of the Pod.

Examples:


spec.source_files = "Classes/**/*.{h,m}"

spec.source_files = "Classes/**/*.{h,m}", "More_Classes/**/*.{h,m}"

Parameters:

  • source_files (String, Array<String>)

    the source files of the Pod.



1015
1016
1017
# File 'lib/cocoapods-core/specification/dsl.rb', line 1015

attribute :source_files,
:container     => Array,
:file_patterns => true

#subspec(name, &block) ⇒ Object

Represents specification for a module of the library.


Subspecs participate on a dual hierarchy.

On one side, a specification automatically inherits as a dependency all it children ‘sub-specifications’ (unless a default subspec is specified).

On the other side, a ‘sub-specification’ inherits the value of the attributes of the parents so common values for attributes can be specified in the ancestors.

Although it sounds complicated in practice it means that subspecs in general do what you would expect:

pod 'ShareKit', '2.0'

Installs ShareKit with all the sharers like ‘ShareKit/Evernote`, `ShareKit/Facebook`, etc, as they are defined as subspecs.

pod 'ShareKit/Twitter',  '2.0'
pod 'ShareKit/Pinboard', '2.0'

Installs ShareKit with only the source files for ‘ShareKit/Twitter`, `ShareKit/Pinboard`. Note that, in this case, the ‘sub-specifications’to compile need the source files, the dependencies, and the other attributes defined by the root specification. CocoaPods is smart enough to handle any issues arising from duplicate attributes.

Examples:

Subspecs with different source files.


subspec "Twitter" do |sp|
  sp.source_files = "Classes/Twitter"
end

subspec "Pinboard" do |sp|
  sp.source_files = "Classes/Pinboard"
end

Subspecs referencing dependencies to other subspecs.


Pod::Spec.new do |s|
  s.name = 'RestKit'

  s.subspec 'Core' do |cs|
    cs.dependency 'RestKit/ObjectMapping'
    cs.dependency 'RestKit/Network'
    cs.dependency 'RestKit/CoreData'
  end

  s.subspec 'ObjectMapping' do |os|
  end
end

Nested subspecs.


Pod::Spec.new do |s|
  s.name = 'Root'

  s.subspec 'Level_1' do |sp|
    sp.subspec 'Level_2' do |ssp|
    end
  end
end


1326
1327
1328
1329
1330
# File 'lib/cocoapods-core/specification/dsl.rb', line 1326

def subspec(name, &block)
  subspec = Specification.new(self, name, &block)
  @subspecs << subspec
  subspec
end

#summary=(summary) ⇒ Object

A short (maximum 140 characters) description of the Pod.


The description should be short, yet informative. It represents the tag line of the Pod and there is no need to specify that a Pod is a library (they always are).

The summary is expected to be properly capitalised and containing the correct punctuation.

Examples:


spec.summary = 'Computes the meaning of life.'

Parameters:

  • summary (String)

    A short description of the Pod.



355
356
# File 'lib/cocoapods-core/specification/dsl.rb', line 355

root_attribute :summary,
:required => true

#tvosPlatformProxy

Provides support for specifying tvOS attributes.

Examples:

spec.tvos.source_files = "Classes/tvos/**/*.{h,m}"

Returns:



1412
1413
1414
# File 'lib/cocoapods-core/specification/dsl.rb', line 1412

def tvos
  PlatformProxy.new(self, :tvos)
end

#user_target_xcconfig=(value) ⇒ Object

Specifies flags to add to the final aggregate target xcconfig file, which propagates to non-overridden and inheriting build settings to the integrated user targets.


This attribute is __not recommended__ as Pods should not pollute the build settings of the user project and this can cause conflicts.

Multiple definitions for build settings that take multiple values will be merged. The user is warned on conflicting definitions for custom build settings and build settings that take only one value.

Typically clang compiler flags or precompiler macro definitions go in here if they are required when importing the pod in the user target. Note that, this influences not only the compiler view of the public interface of your pod, but also all other integrated pods alongside to yours. You should always prefer [‘pod_target_xcconfig`]( guides.cocoapods.org/syntax/podspec.html#pod_target_xcconfig), which can contain the same settings, but only influence the toolchain when compiling your pod target.

Examples:


spec.user_target_xcconfig = { 'MY_SUBSPEC' => 'YES' }

Parameters:

  • value (Hash{String => String})

    Key-value pairs representing build settings.



816
817
818
# File 'lib/cocoapods-core/specification/dsl.rb', line 816

attribute :user_target_xcconfig,
:container => Hash,
:inherited => true

#vendored_frameworks=(*frameworks) ⇒ Object

The paths of the framework bundles that come shipped with the Pod.

Examples:


spec.ios.vendored_frameworks = 'Frameworks/MyFramework.framework'

spec.vendored_frameworks = 'MyFramework.framework', 'TheirFramework.framework'

Parameters:

  • vendored_frameworks (String, Array<String>)

    A list of framework bundles paths.



1083
1084
1085
1086
# File 'lib/cocoapods-core/specification/dsl.rb', line 1083

attribute :vendored_frameworks,
:container => Array,
:file_patterns => true,
:singularize => true

#vendored_libraries=(*frameworks) ⇒ Object

The paths of the libraries that come shipped with the Pod.

Examples:


spec.ios.vendored_library = 'Libraries/libProj4.a'

spec.vendored_libraries = 'libProj4.a', 'libJavaScriptCore.a'

Parameters:

  • vendored_libraries (String, Array<String>)

    A list of library paths.



1105
1106
1107
1108
# File 'lib/cocoapods-core/specification/dsl.rb', line 1105

attribute :vendored_libraries,
:container => Array,
:file_patterns => true,
:singularize => true

#version=(version) ⇒ Object

The version of the Pod. CocoaPods follows [semantic versioning](semver.org).

Examples:


spec.version = '0.0.1'

Parameters:

  • version (String)

    the version of the Pod.



100
101
# File 'lib/cocoapods-core/specification/dsl.rb', line 100

root_attribute :version,
:required => true

#watchosPlatformProxy

Provides support for specifying watchOS attributes.

Examples:

spec.watchos.source_files = "Classes/watchos/**/*.{h,m}"

Returns:



1423
1424
1425
# File 'lib/cocoapods-core/specification/dsl.rb', line 1423

def watchos
  PlatformProxy.new(self, :watchos)
end

#weak_frameworks=(*frameworks) ⇒ Object

A list of frameworks that the user’s target needs to weakly link against.

Examples:


spec.weak_framework = 'Twitter'

Parameters:

  • weak_frameworks (String, Array<String>)

    A list of frameworks names.



722
723
724
725
# File 'lib/cocoapods-core/specification/dsl.rb', line 722

attribute :weak_frameworks,
:container   => Array,
:singularize => true,
:inherited => true