> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# iOS quick start


[readme-version-support-link]:https://github.com/cloudinary/cloudinary_ios#version-support
This quick start lets you get an end-to-end implementation up and running using the iOS SDK in 10 minutes or less.

#### Prerequisites **To perform this quick start, you'll need:**

* A Cloudinary account. If you don't have one yet, you can quickly [register for free](https://cloudinary.com/users/register_free).
* Your product environment credentials. You can find your [credentials](product_environment_settings#api_keys) on the [API Keys](https://console.cloudinary.com/app/settings/api-keys) page of the Cloudinary Console Settings. 
  * To use your **API environment variable**, copy the provided format and replace the `<your_api_key>` and `<your_api_secret>` placeholders with the actual values found on the page. Your cloud name will already be correctly included in the format.
* A working iOS development environment with a [supported version][readme-version-support-link] of iOS.

> **NOTES**:
>
> * This quick start is designed for quick onboarding.  It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.  

> * If you aren't familiar with Cloudinary, you may want to first take a look at the [Developer Kickstart](dev_kickstart) for a hands-on, step-by-step introduction to Cloudinary features. You may also find our [Glossary](cloudinary_glossary) helpful to understand Cloudinary-specific terminology.
## 1. Set up and configure

You will need to complete some initial project set up and configuration. The quick start assumes you will be using Xcode as your IDE.

### Create a new Storyboard project

Create a new empty iOS app project, making sure to select "Storyboard" as the interface.

### Add the Cloudinary iOS SDK package

Add the package as a dependency. This can be done from within your development environment:

1. Select **File > Add Package Dependencies**
2. Add the repository URL: `https://github.com/cloudinary/cloudinary_ios.git`
3. Select "Up to Next Major" with version "5.0.0"

### Import Cloudinary

In your **ViewController**, add the import statement for the Cloudinary SDK below the `UIKit` import.

ViewController.swift

```ios
import UIKit
import Cloudinary

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }


}
```

### Configure Cloudinary

Define your cloud name and initialize Cloudinary.

ViewController.swift

```ios
import UIKit
import Cloudinary

class ViewController: UIViewController {

    let cloudName: String = "<your_cloudname>"
    
    var cloudinary: CLDCloudinary!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initCloudinary()
    }
    private func initCloudinary() {
        let config = CLDConfiguration(cloudName: cloudName, secure: true)
        cloudinary = CLDCloudinary(configuration: config)
    }

}

```

More info about configuration...

You can set any [configuration parameters](cloudinary_sdks#configuration_parameters) in this way. In this case, you're setting the `secure` parameter to ensure that `https` URLs are generated by the SDK.

## 2. Upload an image

Before adding your upload code:

1. Download the following [image](https://raw.githubusercontent.com/adimiz1/docs_ios_sample/master/docs_ios_sample_app/Assets.xcassets/cloudinary_logo.imageset/cloudinary_logo.png) and use the Assets import option to import it to your project assets.
2. Create an unsigned [upload preset](https://console.cloudinary.com/app/settings/upload/presets) (you can use the default settings) or use an existing unsigned preset. See the [upload presets guide](upload_presets) for more information.

Now, copy and paste the code below which:

* Creates a variable for your unsigned upload preset (update this to the name of your newly created preset). 
* Defines an outlet for your uploaded image.
* Creates an upload function.

Update your **ViewController** making sure to replace any variable placeholders:

ViewController.swift

```ios
import UIKit
import Cloudinary

class ViewController: UIViewController {

    let cloudName: String = "<your_cloudname>"
    var uploadPreset: String = "<your_upload_preset>" //NEW - Name of unsigned upload preset
    
    @IBOutlet weak var ivUploadedImage: CLDUIImageView! //NEW - Outlet for uploaded image
    
    var cloudinary: CLDCloudinary!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initCloudinary()
        uploadImage() //NEW - Call upload function
    }
    private func initCloudinary() {
        let config = CLDConfiguration(cloudName: cloudName, secure: true)
        cloudinary = CLDCloudinary(configuration: config)
    }
    //NEW - Upload function
    private func uploadImage() {
        guard let data = UIImage(named: "cloudinary_logo")?.pngData() else {
            return
        }
        cloudinary.createUploader().upload(data: data, uploadPreset: uploadPreset) { response, error in
            DispatchQueue.main.async {
                guard let url = response?.secureUrl else {
                    return
                }
                self.ivUploadedImage.cldSetImage(url, cloudinary: self.cloudinary)
            }
        }
    }

}
```

More info about upload...

* See the `upload` method of the [Upload API](image_upload_api_reference#upload) for more optional parameters.
* Learn more about [uploading assets](upload_images) in general.

## 3. Transform an image

Copy and paste the following code, which:

* Additionally defines a public ID of an image to transform (you can use a sample from your account, such as `cld-sample-5`)
* Creates an outlet for your generated image, and adds a variable for your URL. 
* Adds functions for generating the URL and setting the image view.

Update your **ViewController** making sure to replace any variable placeholders:

ViewController.swift

```ios
import UIKit
import Cloudinary

class ViewController: UIViewController {

    let cloudName: String = "<your_cloudname>"
    var uploadPreset: String = "<your_upload_preset>"
    var publicId: String = "<your_public_id>" //NEW - The public ID of the image to transform
    
    @IBOutlet weak var ivGenerateUrl: CLDUIImageView! //NEW - Outlet for generated URL
    @IBOutlet weak var ivUploadedImage: CLDUIImageView!
    
    var cloudinary: CLDCloudinary!
    var url: String! //NEW - URL variable
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initCloudinary()
        generateUrl() //NEW - Call generate URL function
        uploadImage()
    }
    
    override func viewDidAppear(_ animated: Bool) {
        setImageView()
    }
    
    private func initCloudinary() {
        let config = CLDConfiguration(cloudName: cloudName, secure: true)
        cloudinary = CLDCloudinary(configuration: config)
    }
    
    // NEW - Generate URL function
    private func generateUrl() {
        url = cloudinary.createUrl().setTransformation(CLDTransformation().setEffect("sepia")).generate(publicId)
    }
    
    //NEW - Set image view function
    private func setImageView() {
        ivGenerateUrl.cldSetImage(url, cloudinary: cloudinary)
    }
    
    private func uploadImage() {
        guard let data = UIImage(named: "cloudinary_logo")?.pngData() else {
            return
        }
        cloudinary.createUploader().upload(data: data, uploadPreset: uploadPreset) { response, error in
            DispatchQueue.main.async {
                guard let url = response?.secureUrl else {
                    return
                }
                self.ivUploadedImage.cldSetImage(url, cloudinary: self.cloudinary)
            }
        }
    }

}

```

More info about transformations...

* When the image is delivered via this URL, you will see a transformed version of the image (the original remains intact).
* The applied transformation in this case is applying a sepia effect.
* See the [transformation reference](transformation_reference) for details of all transformations.

## 4. Update your view

Before running your code, you need to add the relevant image views to your **Main** storyboard, one for the transformed image and one for the uploaded image.

The image views need to be updated to use the Cloudinary SDK specific `CLDUIImageView` class and should have a referencing outlet connected, one for each of the outlets defined in the **ViewController**.

Main.storyboard

![iOS quickstart main view](https://cloudinary-res.cloudinary.com/image/upload/dpr_2/f_auto/q_auto/docs/ios_quickstart_view.png "width: 600, popup:true, thumb: w_600")

## 5. Run your code

Run your project, ensuring that you have the relevant iOS version and simulator installed. You should see your two images, one being the Cloudinary logo that was uploaded and the other a transformed image for the public ID that was set.

![iOS quickstart main view](https://cloudinary-res.cloudinary.com/image/upload/dpr_2/f_auto/q_auto/docs/ios_quickstart_demo.png "width: 400, popup:true, thumb: w_600")

## View the completed code

You can find the full code example for this on [GitHub](https://github.com/adimiz1/docs_ios_sample).

## Next steps
* Learn more about the iOS SDK by visiting the other pages in this SDK guide.
* Get comprehensive details about Cloudinary features and capabilities:
    * [Upload guide](upload_images): Provides details and examples of the upload options.
    * [Image transformations guide](image_transformations): Provides details and examples of the transformations you can apply to image assets.
    * [Video transformations guide](video_manipulation_and_delivery): Provides details and examples of the transformations you can apply to video assets.
    * [Transformation URL API Reference](transformation_reference): Provides details and examples of all available transformation parameters. 
    * [Admin API guide](admin_api): Provides details and examples of the methods available for managing and organizing your media assets.
Take a look at the [iOS sample project](ios_sample_projects) for a more comprehensive example using the Cloudinary iOS SDK.
