Cocoapods are helpful libraries that can be added to your Xcode project. One well-known service that uses Cocoapods is Firebase. The process for installing cocoapods is below.
Step 1:
Open the terminal app (Finder>Applications>Utilities>Terminal) and type the following then hit enter to install.
sudo gem install cocoapods
You may have to type y (then hit enter) during the installation.
Step 2:
Now navigate to your project’s directory using cd. An example of navigating to a project’s directory is mentioned below.
cd Documents/Xcode-8/MyApp
//The above is an example. Please type the actual directory of your project.
Step 3:
Intialize the pod using the command below.
pod init
Step 4:
Open the podfile in your text editor program. We recommend Sublime Text.
Add the pods that you would like to install. Please visit the Cocoapods website to find pods and their installation code. An example of a podfile is below.
Please note that some services such as Firebase use multiple podfile for each of their services.
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'Firebase/Core'
pod 'Firebase'
pod "TextFieldEffects"
pod 'GoogleSignIn', '~> 5.0'
pod 'Firebase/Auth'
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
# Pods for testing
end
end
Step 5:
Install the pod using the command below.
pod install
Lastly:
Quit Xcode and all projects and use MYAPP.xcworkspace from now on rather than MYAPP.xcodeproject. These files can be found from finder where you saved the files.