CocoaPods installation

CocoaPods profile

As each language progresses, dependency management tools such as Maven for the Java language and NPM for NodeJS emerge. With the rise of iOS developers, there is a new dependency management tool for iOS applications called CocoaPods. The CocoaPods project source code is managed on Github. The project started on August 12, 2011 and has evolved over the years to become the standard dependency management tool for iOS development implementations. It is inevitable to use third-party open source libraries to develop iOS projects. The emergence of CocoaPods can save the time to set up and update third-party open source libraries. Before using CocoaPods, I need to: Copy the source files from these third-party open source libraries into your project, or set them up as git submodules. For these open source libraries, I need to manually add the framework to the project dependencies. For example, a network library usually requires the following framework: CFNetwork, SystemConfiguration, MobileCoreServices, CoreGraphics, zlib. For some open source libraries, I also need to set compilation parameters such as -licucore or -fno-objc-arc to manage updates to these dependencies. These manual tasks are simple, unskilled and time-consuming. After using CocoaPods, ALL I had to do was put the third-party open source libraries I was using into a file called Podfile and execute Pod Install. CocoaPods automatically downloads the source code from these third-party open source libraries and sets up the system dependencies and build parameters for my project.

The installation

  • The installation mode is simple, the Mac has its own Ruby, ruby gem command can be downloaded and installed
  • sudo gem install cocoapods
  • pod setup
  • gem -v// Obtain the gem version information and check whether the current version is the latest. Otherwise, update the gem version in the next step
  • gem update --system// Administrator privileges may be required,sudo
  • gem sources --remove https://rubygems.org/// Remove the old Ruby source
  • gem sources -a https://ruby.taobao.org/// Replace with a taobao mirror
  • gem sources -l// Check whether the configuration is successful
  • sudo gem install cocoapods// To install cocoaPods, you need to enter the login password of your computer

Install tripartite library files

  • pod setup

  • Drag the project file to the terminal to obtain the current project path

  • Touch Podfile // To create a Podfile, run the touch command -new

  • Open Podfile // Open open command with Xcode

  • Add to podFile

  • Pod Search AFNetworking // Search third-party libraries

  • Pod install –verbose –no-repo-update checks the installation progress and ignores unnecessary installation procedures

Delete the installation

  1. Open the Podfile file and delete the JSONKit line, that is:
  • Platform: ios, ‘7.0’
  • Pod ‘AFNetworking’, ‘~ > 2.1.0’
  • Pod ‘JSONKit’, ‘~> 1.5pre’
  • Pod ‘MBProgressHUD’, ‘~ > 0.8’
  • (If you want to change to 1.1, change the deleted line to POD ‘JSONKit -nowarning ‘, ‘~> 1.1’)
  1. CD Go to the current project directory and run the pod install command again. The output is as follows (note the Removing JSONKit) :
  • $ pod install

Analyzing Dependencies Removing JSONKit Downloading Dependencies Using AFNetworking (2.1.0) Using MBProgressHUD Generating Pods project Integrating client project