Skip to main content
Noble Desktop Publishing Team/3 min read

Cocoapods Dependency Manager

iOS Development Essentials

Swift

Apple's modern language — type-safe, fast, expressive.

Xcode

The IDE — code editor, simulator, debugger, profiler in one.

UIKit / SwiftUI

Old vs new UI frameworks — SwiftUI is the future.

App Store Distribution

Provisioning, signing, and the review process.

Build Programming Foundations at Noble Desktop

Noble Desktop's Full-Stack Web Development Certificate teaches programming fundamentals that transfer across mobile, web, and desktop development.

Master the essentials of iOS development with this tutorial, covering topics like Cocoapods Dependency Manager and installing packages, while providing a hands-on exercise in managing project dependencies.

Topics Covered in This IOS Development Tutorial:

Installing Cocoapods Dependency Manager, Installing Packages Using Cocoapods

Exercise Overview

Dependencies are libraries of code that another library needs to run. Remember back to an earlier exercise when we imported MapKit to our Jive Factory app? That was a dependency that we added to the project.

We will use a utility called CocoaPods, which allows developers to easily add libraries and dependencies to projects. It is commonly the case that you may want to use one library, but because it is dependent on other libraries, you’ll need to add (and maintain) them as well in order for the one library to work. CocoaPods helps simplify things for developers who want to install a library by maintaining any additional dependencies.

Installing CocoaPods

  1. Go into your Applications > Utilities folder and launch Terminal.
  2. In Terminal, install CocoaPods by typing:

    sudo gem install cocoapods
  3. Hit Return.
  4. Next to Password: type in your computer’s password (the password won’t show in Terminal but don’t worry, it’s there).
  5. Hit Return.

Once Cocoapods is ready to go, we can begin installing dependencies! Create a new project called Pod Factory. We installed Firebase using the Swift Package Manager in our Jive Factory app, we are going to use Cocoapods in this bonus exercise instead.

  1. Click on the Pod Factory project name (not the folder) at the top of the Project navigator to open the Project Settings Editor.
  2. Go to File > New > File (Cmd–N).
  3. In the Filter text box search for Empty, scroll down to the Other section and double–click on Empty.
  4. Next to Save As, type: Podfile
  5. You should be in the Pod Factory folder, so click Create.
  6. In the Project navigator, make sure Podfile is selected.
  7. It is currently blank. Type:

    target "Pod Factory" do
    pod 'Firebase/Database'
    end

NOTE: Each pod consists of a library and its dependencies.

  1. Close and save the Xcode project.

  2. Now we need to navigate to our Podfile in the Terminal. Open Terminal (Applications > Utilities > Terminal) if it isn’t already open, then type cd followed by a single space.

    NOTE: cd stands for change directory.

  3. There is an easy way of specifying a path in Terminal. Open a Finder window and navigate to: Desktop > Class Files > Pod Factory
  4. Drag the Pod Factory folder and drop it onto the Terminal window.
  5. Return to Terminal. You should see the path has automatically been entered.
  6. Hit Return. Now we are inside the Pod Factory folder.
  7. Type the following:

    pod install
  8. Hit Return and wait for installation to complete. It could take several moments.

    NOTE: If you encounter errors completing the pod installation, you may need to update to new pods. In your Terminal, type pod update and hit Return. Once this completes, you will need to type pod install and hit Return again.

    Feel free to read more about the Firebase setup by going to firebase.Google.com/docs/iOS/setup.

  9. Once Terminal is done installing the pod, go back to Xcode and make sure the Pod Factory project is not open.

  10. In a Finder window, navigate into: Desktop > Class Files > Pod Factory

  11. Notice a new file called Pod Factory.xcworkspace has been created. Open it.

    NOTE: You should now work from this file instead of the Pod Factory.xcodeproj file.

  12. In the Project navigator, notice there are two targets: Pod Factory and Pods

You have successfully installed Firebase with Cocoapods! You can now follow the same Jive Factory project steps to build a working Firebase app with Cocoapods as the dependency manager.