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](commands.html#tab_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 |s|
  s.name         = 'Reachability'
  s.version      = '3.1.0'
  s.license      = { :type => 'BSD' }
  s.homepage     = 'https://github.com/tonymillion/Reachability'
  s.authors      = { 'Tony Million' => '[email protected]' }
  s.summary      = 'ARC and GCD Compatible Reachability Class for iOS and OS X. Drop in replacement for Apple Reachability.'
  s.source       = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }
  s.source_files = 'Reachability.{h,m}'
  s.framework    = 'SystemConfiguration'
  s.requires_arc = true
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],
  :svn   => [:folder, :tag, :revision],
  :hg    => [:revision],
  :http  => nil,
  :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].freeze

File patterns These paths should be specified **relative** to the **root** of the source and 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

RESOURCES_DESTINATIONS =

The possible destinations for the ‘resources` attribute. Extracted form `Xcodeproj::Constants.COPY_FILES_BUILD_PHASE_DESTINATIONS`.

[
  :products_directory,
  :wrapper,
  :resources,
  :executables,
  :java_resources,
  :frameworks,
  :shared_frameworks,
  :shared_support,
  :plug_ins,
].freeze

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 These paths should be specified **relative** to the **root** of the source and 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

Hooks The specification class provides hooks which are called by CocoaPods when a Pod is installed. 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

Class Method Summary collapse

Methods included from AttributeSupport

attribute, root_attribute

Class Method Details

.attributesArray<Attribute>

Returns The attributes of the class.

Returns:

  • (Array<Attribute>)

    The attributes of the class.



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

def self.attributes
  @attributes
end

Instance Method Details

#authors=(authors) ⇒ Object

The name and email address of each of the library’s the authors.

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.



126
127
128
129
130
131
# File 'lib/cocoapods-core/specification/dsl.rb', line 126

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

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



552
553
554
555
556
# File 'lib/cocoapods-core/specification/dsl.rb', line 552

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

#default_subspec=(subspec_name) ⇒ Object

The name of the subspec 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 = 'Pod/Core'

Parameters:

  • subspec_name (String)

    the name of the subspec that should be inherited as dependency.



1102
1103
1104
# File 'lib/cocoapods-core/specification/dsl.rb', line 1102

attribute :default_subspec, {
  :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 approximate 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'

Raises:



438
439
440
441
442
443
444
445
# File 'lib/cocoapods-core/specification/dsl.rb', line 438

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

#deployment_target=(*args) ⇒ Object

The deployment targets of the supported platforms.

Examples:


spec.ios.deployment_target = "6.0"

spec.osx.deployment_target = "10.8"

Parameters:

  • args (String)

    The deployment target of the platform.

Raises:



393
394
395
# File 'lib/cocoapods-core/specification/dsl.rb', line 393

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

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



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

root_attribute :description

#documentation=(documentation) ⇒ Object

Additional options to pass to the [appledoc](gentlebytes.com/appledoc/) tool.

Examples:


spec.documentation = { :appledoc => ['--no-repeat-first-par',
                                     '--no-warn-invalid-crossref'] }

Parameters:

  • documentation (Hash{Symbol=>Array<String>})

    Additional options to pass to the appledoc tool.



318
319
320
# File 'lib/cocoapods-core/specification/dsl.rb', line 318

root_attribute :documentation, {
  :container => Hash,
}

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



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

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

#frameworks=(*frameworks) ⇒ Object

A list of 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.



489
490
491
492
493
# File 'lib/cocoapods-core/specification/dsl.rb', line 489

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.



641
642
643
# File 'lib/cocoapods-core/specification/dsl.rb', line 641

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.



659
660
661
# File 'lib/cocoapods-core/specification/dsl.rb', line 659

attribute :header_mappings_dir, {
  :inherited => true
}

#homepage=(homepage) ⇒ Object

The URL of the homepage of the Pod.

Examples:


spec.homepage = 'www.example.com'

Parameters:

  • homepage (String)

    the URL of the homepage of the Pod.



193
194
195
# File 'lib/cocoapods-core/specification/dsl.rb', line 193

root_attribute :homepage, {
  :required => true,
}

#iosPlatformProxy

Provides support for specifying iOS attributes.

Examples:

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

Returns:



1130
1131
1132
# File 'lib/cocoapods-core/specification/dsl.rb', line 1130

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

#libraries=(*libraries) ⇒ Object

A list of 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.



533
534
535
536
537
# File 'lib/cocoapods-core/specification/dsl.rb', line 533

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.

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})

    The type of the license and the text of the grant that allows to use the library (or the relative path to the file that contains it).



174
175
176
177
178
# File 'lib/cocoapods-core/specification/dsl.rb', line 174

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

#name=(name) ⇒ Object

The name of the Pod.

Examples:


spec.name = 'AFNetworking'

Parameters:

  • name (String)

    the name of the pod.



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

root_attribute :name, {
  :required => true,
}

#osxPlatformProxy

Provides support for specifying OS X attributes.

Examples:

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

Returns:



1141
1142
1143
# File 'lib/cocoapods-core/specification/dsl.rb', line 1141

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.



367
368
369
370
371
372
373
374
375
376
# File 'lib/cocoapods-core/specification/dsl.rb', line 367

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

#post_install(&block) ⇒ Object

This is a convenience method which gets called after all pods have been downloaded, installed, and the Xcode project and related files have been generated. Note that this hook is called for each Pods library and only for installations where the Pod is installed.

To modify and generate files for the Pod the pre install hook should be used instead of this one.

It receives a [‘Pod::Hooks::LibraryRepresentation`](docs.cocoapods.org/cocoapods/pod/hooks/libraryrepresentation/) instance for the current target.

Override this to, for instance, add to the prefix header.

Examples:


spec.post_install do |library_representation|
  prefix_header = library_representation.prefix_header_path
  prefix_header.open('a') do |file|
    file.puts('#ifdef __OBJC__\n#import "SSToolkitDefines.h"\n#endif')
  end
end


991
992
993
# File 'lib/cocoapods-core/specification/dsl.rb', line 991

def post_install(&block)
  @post_install_callback = block
end

#pre_install(&block) ⇒ Object

This is a convenience method which gets called after all pods have been downloaded but before they have been installed, and the Xcode project and related files have been generated. Note that this hook is called for each Pods library and only for installations where the Pod is installed.

This hook should be used to generate and modify the files of the Pod.

It receives the [‘Pod::Hooks::PodRepresentation`](docs.cocoapods.org/cocoapods/pod/hooks/podrepresentation/) and the [`Pod::Hooks::LibraryRepresentation`](docs.cocoapods.org/cocoapods/pod/hooks/libraryrepresentation/) instances.

Override this to, for instance, to run any build script.

Examples:


spec.pre_install do |pod, target_definition|
  Dir.chdir(pod.root){ `sh make.sh` }
end


964
965
966
# File 'lib/cocoapods-core/specification/dsl.rb', line 964

def pre_install(&block)
  @pre_install_callback = block
end

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



598
599
600
601
# File 'lib/cocoapods-core/specification/dsl.rb', line 598

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.



622
623
624
# File 'lib/cocoapods-core/specification/dsl.rb', line 622

attribute :prefix_header_file, {
  :inherited => true
}

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



927
928
929
930
931
# File 'lib/cocoapods-core/specification/dsl.rb', line 927

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.



805
806
807
808
# File 'lib/cocoapods-core/specification/dsl.rb', line 805

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 are considered public.

Examples:


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

Parameters:

  • public_header_files (String, Array<String>)

    the public headers of the Pod.



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

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

#requires_arc=(flag) ⇒ Object

Wether the library requires ARC to be compiled. If true the ‘-fobjc-arc` flag will be added to the compiler flags.


The default value of this attribute is __transitioning__ from ‘false` to `true`, and in the meanwhile this attribute is always required.

Examples:


spec.requires_arc = true

Parameters:

  • flag (Bool)

    whether the source files require ARC.



466
467
468
469
470
# File 'lib/cocoapods-core/specification/dsl.rb', line 466

attribute :requires_arc, {
  :types => [TrueClass, FalseClass],
  :default_value => false,
  :inherited => true,
}

#resources=(resources) ⇒ Object

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

Examples:


spec.resource = "Resources/HockeySDK.bundle"

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

Parameters:

  • resources (String, Array<String>)

    the resources of the Pod.



826
827
828
829
830
# File 'lib/cocoapods-core/specification/dsl.rb', line 826

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.

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.



298
299
300
301
# File 'lib/cocoapods-core/specification/dsl.rb', line 298

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

#source=(source) ⇒ Object

The location from where the library should be retrieved.

Examples:

Specifying a Git source with a tag.


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

Using the version of the Pod to identify the Git tag.


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

Parameters:

  • source (Hash{Symbol=>String})

    The location from where the library should be retrieved.



226
227
228
229
230
# File 'lib/cocoapods-core/specification/dsl.rb', line 226

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.



756
757
758
759
# File 'lib/cocoapods-core/specification/dsl.rb', line 756

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 a 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


1071
1072
1073
1074
1075
# File 'lib/cocoapods-core/specification/dsl.rb', line 1071

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 capitalized and containing the correct punctuation.

Examples:


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

Parameters:

  • summary (String)

    A short description of the Pod.



254
255
256
# File 'lib/cocoapods-core/specification/dsl.rb', line 254

root_attribute :summary, {
  :required => 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
102
# File 'lib/cocoapods-core/specification/dsl.rb', line 100

root_attribute :version, {
  :required => true,
}

#weak_frameworks=(*frameworks) ⇒ Object

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

Examples:


spec.framework = 'Twitter'

Parameters:

  • weak_frameworks (String, Array<String>)

    A list of frameworks names.



509
510
511
512
513
# File 'lib/cocoapods-core/specification/dsl.rb', line 509

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

#xcconfig=(value) ⇒ Object

Any flag to add to the final xcconfig file.

Examples:


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

Parameters:

  • value (Hash{String => String})

    A representing an xcconfig.



571
572
573
574
# File 'lib/cocoapods-core/specification/dsl.rb', line 571

attribute :xcconfig, {
  :container => Hash,
  :inherited => true,
}