Episode #28

Creating a Cocoapod

13 minutes
Published on August 9, 2012
In this episode, we'll create a CocoaPod out of the modal picker view component we created in episodes 25 & 26. We'll see how to tag & push our code to a github repository and create a podspec so that others can use this component in their projects.

Links

Creating a Podspec

pod spec create

This will create the example MyProject.podspec file that you need to fill out.

Filling out the Podspec File

Pod::Spec.new do |s|
  s.name         = "BSModalPickerView"
  s.version      = "0.1"
  s.summary      = "A custom UIPickerView with a simple list of options, along with a toolbar for Done/Cancel and a faded backdrop view."
  s.homepage     = "https://github.com/subdigital/BSModalPickerView"

  s.license      = { :type => 'MIT', :file => 'LICENSE' }
  s.author       = { "Ben Scheirman" => "ben@scheirman.com" }
  s.source       = { 
    :git => "https://github.com/subdigital/BSModalPickerView.git", 
    :tag => "0.1"
  }

  s.platform     = :ios, '4.0'
  s.source_files = '*.{h,m}'
  s.requires_arc = true
end

Verifying that the Podspec is Valid

pod spec lint MyProject.podspec

Adding the Podspec to the CocoaPods Specs Repo

  1. Fork the repository at http://github.com/CocoaPods/Specs.git
  2. Add your podspec file to its own versioned folder
  3. Push to your fork
  4. Issue a Pull Request

Pushing Podspecs to Custom Repositories

If you want to publish your podspec to a custom repository, you can follow these instructions on the wiki.

Want more? Subscribers can view all 573 episodes. New episodes are released regularly.

Subscribe to get access →

Source Code

View on GitHub Download Source