# CocoaPods

### What is CocoaPods?

CocoaPods is a dependency manager for Swift and Objective-C projects in Xcode. It is used in over 3 million apps and contains over 95 thousand libraries. It is similar to **pip** for Python and **npm** for NodeJS. In other words, you can use code written by other people in your own Xcode project to make your life easier!

### CocoaPods Setup

1. To install CocoaPods, simply run the following in the command line: `sudo gem install cocoapods`
2. Navigate to your Xcode project directory and run this command: `pod init`. This creates a `Podfile` in your directory.
3. Open the `Podfile` and list out the pods you want to install. For example, if I wanted to install the latest version of **SnapKit** and **Alamofire**, my `Podfile` would look something like this:

```
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'MyApp' do
  use_frameworks!

  # Pods for MyApp

  pod 'SnapKit'
  pod 'Alamofire'
end
```

*Change ‘MyApp’ to the name of your project.*

1. Once you are done, save your `Podfile` and install the dependencies by running `pod install`
   * If this command does not work, try `pod install --repo-update`

{% hint style="danger" %}
**You must open the Xcode workspace instead of the project when using CocoaPods!**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ios-course.cornellappdev.com/resources/tool-guides/cocoapods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
