Swift and SwiftUI images from Supabase Storage
The Swift package includes a typed URL builder, SwiftUI AsyncImage integration, and a UIKit helper. It shares the same conformance fixtures as the JavaScript SDKs.
SDK coming soon
ProdKit (Swift package) isn't published yet, so the guides below skip the install step. Until it is, build image URLs from your endpoint with URL parameters. They work in any Swift app with no package:
URL API
AsyncImage(url: URL(string: "https://img.prodkit.cloud/acme/avatars/cory.png?width=256")) { image in
image.resizable().scaledToFill()
} placeholder: {
ProgressView()
}
.frame(width: 128, height: 128)Build typed URLs
ProdKitClient validates configuration, rewrites Supabase public storage URLs, clamps transforms, and returns Foundation URLs.
Example
import ProdKit
let prodkit = ProdKitClient(project: "acme")
let url = try prodkit.url(
for: "covers/launch.jpg",
transform: ProdKitTransform(width: 1280, height: 720, quality: 82)
)Crop to faces and remove backgrounds
Crop and effect options are typed. .face gravity uses Cloudflare's face detection; removeBackground (beta) returns a transparent cutout.
Example
let avatar = try prodkit.url(
for: "avatars/cory.png",
transform: ProdKitTransform(width: 96, height: 96, gravity: .face, zoom: 0.6)
)
let cutout = try prodkit.url(
for: "products/sneaker.jpg",
transform: ProdKitTransform(width: 800, removeBackground: true)
)Render with SwiftUI
ProdKitAsyncImage wraps SwiftUI AsyncImage while keeping transform options typed.
Example
ProdKitAsyncImage(
"covers/launch.jpg",
client: prodkit,
transform: ProdKitTransform(width: 1280, height: 720)
) { image in
image.resizable().scaledToFill()
} placeholder: {
ProgressView()
}Use UIKit
UIKit projects can build URLs manually or use the UIImageView helper for simple async loading.
Example
let imageView = UIImageView()
imageView.setProdKitImage(
"avatars/cory.png",
client: prodkit,
transform: ProdKitTransform(width: 256, height: 256)
)Swift API
ProdKitClient, ProdKitTransform, ProdKitFit, and ProdKitFormat provide typed access to the same URL behavior as the JavaScript SDKs. Width and height are pixel values; multiply by screen scale when you want point-based sizing.
| Name | Description | Values | Default |
|---|---|---|---|
| ProdKitClient | Holds project and imageBaseURL configuration. | project, imageBaseURL | Required project |
| ProdKitTransform | Typed transform values passed to the URL builder and SwiftUI/UIKit helpers. | width, height, quality, fit, format, dpr | No transform |
| ProdKitFit | How the image fills the requested dimensions. | .scaleDown, .contain, .cover, .crop, .pad | .scaleDown |
| ProdKitFormat | Output format. | .auto, .avif, .webp, .jpeg, .png | .auto |
| ProdKitGravity | Where cover and crop fits keep the image. .face uses face detection; .auto finds the most interesting region. Implies .cover unless you set a fit. | .auto, .face, .top, .bottom, .left, .right, .point(x:y:) | Center |
| Effects | ProdKitTransform also takes zoom (0-1, with .face), blur (1-250), sharpen (0-10), and removeBackground (beta). ProdKitClient.placeholderURL(for:transform:) returns a tiny blurred version for loading states. | zoom, blur, sharpen, removeBackground | None |