Blog

Introducing Our Official SDK for Swift

Introducing our official SDK for Swift

Have you ever wanted to access precision-driven image optimization and processing API (you know, such as Optidash) from within your iOS and MacOS applications? If the answer is “yes”, we have something for you - the offcial Swift SDK for Optidash API.

Quick example

Swift SDK, developed by our friends at Inspace Labs, is available for iOS and MacOS developers and covers the entire Optidash API. You can find the latest source code on our GitHub.

Let’s have a look at an example request using Image Upload on iOS:

let fileUrl = Bundle.main.url(forResource: "sample", withExtension: "jpg")!

let resizeParams: [String : Any] = [
    "mode": "fit",
    "gravity": "face",
    "width": 640,
    "height": 480
]

let opti = OptidashClient(key: "YOUR-API-KEY")

do {
    try opti.upload(fileUrl: fileUrl)
            .resize(resizeParams)
            .toImageData() { [weak self] (result) in
                switch (result) {
                case .success(let data):
                    DispatchQueue.main.async {
                        let image = UIImage(data: data)
                        self?.outputImageView.image = image
                    }
                case .failure(let error):
                    DispatchQueue.main.async {
                        self?.outputLabel.text = "Error: \(error)"
                    }
                }
            }
} catch let error {
    outputLabel.text = "Error: \(error)"
}

Installation with Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application. You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Optidash into your Xcode project using Carthage, specify it in your Cartfile:

github "optidash-ai/optidash-swift"

Installation with CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To integrate Optidash into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
pod 'Optidash', '~> 1.0.0'

Should you have questions about Swift SDK or requests for other integrations do not hesitate to contact us anytime.

Ready to try Optidash?

Start optimizing your images smarter. Integrate in minutes.

Create Free Account Get In Touch

This website uses cookiesBy using Optidash, you agree to our Cookie Policy.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.