Setup of Swift SDK

The Aspose.BarCode Cloud SDK for Swift allows you to easily integrate barcode generation and recognition functionality into your Swift applications. This guide will walk you through the setup process using the GitHub repository and Swift Package Manager or CocoaPods .

Prerequisites

  • Swift 6.0 or later, iOS 15.0 or later, macOS 12.0 or later, tvOS 15.0 or later, watchOS 8.0 or later
  • An Aspose Cloud account. Sign up for free on Aspose.Cloud to obtain your Client Id and Client Secret. More information about it on Quickstart page.

Installing the SDK

You can install the Aspose.BarCode Cloud SDK via Swift Package Manager or CocoaPods:

The AsposeBarcodeCloud pod is not published to the CocoaPods trunk repository yet, so use Swift Package Manager until it becomes available. For CocoaPods, add the pod to your Podfile:

pod 'AsposeBarcodeCloud', '~> 26.9'

For Swift Package Manager, add the package dependency to Package.swift:

.package(url: "https://github.com/aspose-barcode-cloud/Aspose.BarCode-Cloud-SDK-for-Swift.git", from: "26.9.0")

Setting Up the Configuration

The AsposeBarcodeCloudClient class is essential for setting up the SDK. It manages your API credentials, base URLs, and other settings.

Basic Configuration

First, import the required namespaces:

import AsposeBarcodeCloud

Then, set up the configuration:

let client = AsposeBarcodeCloudClient(
    clientId: "<Your-Client-Id>",
    clientSecret: "<Your-Client-Secret>"
)

This basic setup will use the default values for API base url, token url and other options which are optimized for general use.

Using the SDK

Once configured, pass the configuration object to initialize API clients. Here’s an example:

let imageData = try await GenerateAPI.generate(
    barcodeType: .qr,
    data: "Aspose.BarCode Cloud",
    barcodeImageParams: BarcodeImageParams(imageFormat: .png),
    apiConfiguration: client.apiConfiguration
)

Now you can call SDK functions.

Conclusion

This documentation has provided the necessary steps to configure and initialize the Aspose.BarCode Cloud SDK for Swift. Refer to the other sections of the Developer Guide for more detailed usage examples.