Skip to main content
Platform:
Language:
Framework:

Get started with CE.SDK Engine

In this example, we will show you how to initialize the CreativeEditor SDK's engine in your macOS app. The engine enables you to power your own UI and creative workflows. Whether you want to keep your current UI or design a new one from scratch, our API can do the heavy lifting for you no matter what your starting point is.

Explore a full code sample on Github .

Requirements#

Creative Engine requires macOS 12 and Swift 5.10 (Xcode 15.4) or later.

Using Swift Package Manager#

If you use Swift Package Manager to build your app and want to integrate the Creative Engine module using your regular workflows, add the IMGLYEngine Swift Package as a dependency to your project.



Using Cocoapods#

Creative Engine is also available through CocoaPods. To install it, simply add the following line to your Podfile: pod 'IMGLYEngine'. Then run pod install --repo-update to install the latest version of the SDK.

Import#

You can get started right away by importing the CESDK module into your own code.

Initialization#

To initialize IMGLYEngine for SwiftUI call the awaitable Engine(license: userID:) initializer. Once the engine is ready pass it to your SwiftUI view.

Licensing#

In the awaitable initializer there are 2 arguments that are tied to your licensing.

  • license - an API key that you downloaded from our dashboard.
  • userID - An optional unique ID tied to your application's user. This helps us accurately calculate monthly active users (MAU). Especially useful when one person uses the app on multiple devices with a sign-in feature, ensuring they're counted once. Providing this aids in better data accuracy.

If the license is invalid, the engine will not start and throw an error.

Use @StateObject property wrapper in your SwiftUI view to store the engine instance and then use it to create a Canvas view.

Use the Creative Engine#

After these setup steps, you can use our APIs to interact with the Creative Engine. The next couple of pages will document the methods available.

import IMGLYEngine
import SwiftUI
struct IntegrateWithSwiftUI: View {
@State private var engine: Engine?
var body: some View {
Group {
if let engine {
ContentView(engine: engine)
} else {
ProgressView()
}
}
.onAppear {
Task {
engine = try await Engine(license: secrets.licenseKey, userID: "<your unique user id>")
}
}
}
}
struct ContentView: View {
@StateObject private var engine: Engine
init(engine: Engine) {
_engine = .init(wrappedValue: engine)
}
var body: some View {
ZStack {
Canvas(engine: engine)
Button("Use the Engine") {
Task {
let url = URL(string: "https://cdn.img.ly/assets/demo/v1/ly.img.template/templates/cesdk_postcard_1.scene")!
try await engine.scene.load(from: url)
try engine.block.find(byType: .text).forEach { id in
try engine.block.setOpacity(id, value: 0.5)
}
}
}
}
}
}