Programmable Media

iOS quick start

Last updated: Jul-19-2024

This quick start lets you get an end-to-end implementation up and running using the iOS SDK in 10 minutes or less.

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

Configure Cloudinary

Define your cloud name and initialize Cloudinary.

ViewController.swift

2. Upload an image

Before adding your upload code:

  1. Download the following image and use the Assets import option to import it to your project assets.
  2. Create an unsigned upload preset (you can use the default settings) or use an existing unsigned preset. See the upload presets guide 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

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

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

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

View the completed code

You can find the full code example for this on GitHub.

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:

Take a look at the iOS sample project for a more comprehensive example using the Cloudinary iOS SDK.

✔️ Feedback sent!

Rate this page: