Make their open source projects integrated support CocoaPods

Usually we often integrated with third-party libraries CocoaPods, how to make your own code that can be integrated by CocoaPods it? Just a few simple steps:

  1. Create a git repository, or to submit code to Github code yun
  2. Creating .Podspec file in git repository, which modify the configuration (such as the version of the code, Profile, git repository address, etc.)
  3. CocoaPods .Podspec submitted to the
    next with a practical example to explain in detail JXCalendarTool

First, the source code will be submitted to Github

About this step please refer to the article: GitHub and Git entry

Second, create and modify files .Podspec

cd to the project directory, create a <project name> .Podspec file with the following command

pod spec create JXCalendarTool

At this point in the project directory has been created JXCalendarTool.Podspec file
Here Insert Picture Description
utilization Xcode or Sublime text editor to open for editing. Remove content <#> annotated, mainly configure these options: do |s|         = "JXCalendar"
  s.version      = "1.0.0"
  s.summary      = "添加行程到系统日历"
  s.homepage     = ""
  s.license      = "MIT"       = { "Jack" => "[email protected]" }
  s.platform = :ios
  s.platform = :ios, "7.0"
  s.source       = { :git => "", :tag => "1.0.0" }
  s.source_files  = "JXCalendarTool", "*.{h,m}"
  s.frameworks  = "UIKit","Foundation","EventKit"
  s.requires_arc = true

  • name of the library.
  • s.version: version number.
  • s.summary: abstract, brief description of the role of open source libraries.
  • s.homepage: project home address.
  • s.license: license, but not to fill MIT, specifically online search under MIT license.
  • Author.
  • s.platform: Support minimum SDK version
  • s.source: git tag address and the corresponding
  • s.source_files: contains the file (root folder JXCalendarTool all .h and .m file)
  • s.framework: system library dependent, is also possible by providing additional s.libraries, s.dependency added lib and a third party open source library dependency

Configuration Reference:

In s.source, we set up tag => "1.0.0", that is our code tag in the Github. We need to create this tag in git in and submit to Github:

git tag '1.0.0'
git push --tags

At this point, Github will have a tag for the branch in 1.0.0:
Here Insert Picture Description

Here Insert Picture Description

Third, the .Podspec submitted to CocoaPods

  1. First, we use pod trunk register <mailbox> '<nickname>' command to register an account CocoaPods
pod trunk register [email protected] 'jackxu'

Here Insert Picture Description
CocoaPods registered mail will send email, click the link to open the mailbox can be activated.

  1. Use pod lib lint command to try to compile, if there is a warning, you can add -allow-warnings later to ignore the warning, successful will display passed validation
pod lib lint --allow-warnings
  1. By pod trunk push the library name .podspec --allow-warnings to be pushed to the remote cocoapods.
pod trunk push JXCalendarTool.podspec --allow-warnings

Then wait patiently success message right

Here Insert Picture Description

Fourth, the use CocoaPods search

  1. At a time when the code has been submitted to the CocoaPods, but the local library to retrieve or old, we need to update CocoaPods local search database with the following command
pod repo update
  1. Until then you can find us by searching command library
pod search JXCalendarTool

Here Insert Picture Description

  1. But sometimes, but still not updated, then clear all cache, re-indexing.
pod cache clean --all
rm -rf ~/Library/Caches/CocoaPods
pod repo update

At this point re-search on it.

Published 103 original articles · won praise 55 · views 380 000 +

Guess you like