Step 1 : Open terminal and type:
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 83 thousand libraries and is used in over 3 million apps. CocoaPods can help you scale your projects elegantly. CocoaPods is built with Ruby and is installable with the default Ruby available on macOS. We recommend you use the default ruby. Steps to install Cocoapods. Cocoapods is used in Xcode IDE for development from iOS apps using Objective-C/Swift. Cocoapods helps developers add external libraries to their iOS project easily. The following tutorial guides you on the steps to install Cocoapods on your Mac in order to make use of its features.
- Brew install cocoapods. Dependency manager for Cocoa projects. Installation support provided for macOS releases: Intel: big sur:: catalina.
- After Mac OS X 10.11 sudo gem install -n /usr/local/bin cocoapods. Since the system of this machine is 10.15, choose the latter command input sudo gem install -n /usr/local/bin cocoapods. Sudo gem install -n /usr/local/bin cocoapods Successfully installed cocoapods-1.8.4 Parsing documentation for cocoapods-1.8.4 Done installing documentation.
Gem will get installed in Ruby inside System library. Or try on 10.11 Mac OSX El Capitan, type:
If there is an error “activesupport requires Ruby version >= 2.xx”, then install latest activesupport first by typing in terminal.
Step 2 : After installation, there will be a lot of messages, read them and if no error found, it means cocoapods installation is done. Next, you need to setup the cocoapods master repo. Type in terminal:
pod setup
And wait it will download the master repo. The size is very big (370.0MB at Dec 2016). So it can be a while. You can track of the download by opening Activity and goto Network tab and search for git-remote-https. Alternatively you can try adding verbose to the command like so:
pod setup --verbose
Step 3 : Once done it will output “Setup Complete”, and you can create your XCode project and save it.
Step 4 : Then in terminal cd to “your XCode project root directory” (where your .xcodeproj file resides) and type:
pod init
Step 5 : Then open your project’s podfile by typing in terminal:
open -a Xcode Podfile
Step 6 : Your Podfile will get open in text mode. Initially there will be some default commands in there. Here is where you add your project’s dependencies. For example, in the podfile, type
How To Update Cocoapods In Mac
pod 'AFNetworking', '0.9.1'
(this line is an example of adding the AFNetworking library to your project).
Other tips:
Uncomment platform :ios, '8.0'
Uncomment user_frameworks!
if you’re using Swift
When you are done editing the podfile, save it and close XCode.
Step 7 : Then install pods into your project by typing in terminal:
pod install
Depending how many libraries you added to your podfile for your project, the time to complete this varies. Once completed, there will be a message that says
Install Cocoapods In Mac Catalina
“Pod installation complete! There are X dependencies from the Podfile and X total pods installed.”
Now close your xcode project and open .xcworkspace xcode project file and start coding. 🙂
Hope you find this blog useful. Please feel free to contact with me in case you have any query, suggestions. You can comment, like and follow posts.
You can request any topic related to Swift and iOS development.
<What is CocoaPods
CocoaPods manages library dependencies for your Xcode projects.
The dependencies for your projects are specified in a single text file called a Podfile. CocoaPods will resolve dependencies between libraries, fetch the resulting source code, then link it together in an Xcode workspace to build your project.
Ultimately the goal is to improve discoverability of, and engagement in, third party open-source libraries by creating a more centralised ecosystem.
<Prefer video?
Google have created a great overview for Route 85 video series going through this entire guide and more.
<Getting Started
<Installation
CocoaPods is built with Ruby and it will be installable with the default Rubyavailable on macOS. You can use a Ruby Version manager, however we recommend thatyou use the standard Ruby available on macOS unless you know what you're doing.
Using the default Ruby install will require you to use sudo
when installinggems. (This is only an issue for the duration of the gem installation, though.)