0

I'm just exploring how CocoaPods is solving the library dependency problem in Xcode. I'm a little confused about the .podspec files. What is the purpose of the podspec file? I also read somewhere that podspec files are generated by some volunteer group, is this true?

Keith Smiley
  • 61,481
  • 12
  • 97
  • 110
venky
  • 1,155
  • 1
  • 11
  • 26

1 Answers1

1

Podspecs are definition files for how CocoaPods (the tool) should install a 3rd party library into your project. Here is the documentation on how a podspec works. Here is a basic example:

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' => 'tonymillion@gmail.com' 
  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

You can see a few self-explanatory attributes here to how this works, the most important for the functionality being the source_files which shows CocoaPods which files need to be included into the project.

As with most things in the open source community there are many contributors to the CocoaPods specs repo which is where all the podspec files are added for CocoaPods. Many people who publish their own open source libraries add podspecs there themselves, others are added by people who just want to include them with CocoaPods.

Keith Smiley
  • 61,481
  • 12
  • 97
  • 110