ImagePlayground framework now uses powerful server-side models via Private Cloud Compute to generate high-quality images in virtually any style, including photorealistic ones. The old on-device ImageCreator API is deprecated; everything flows through a new sheet-based API with built-in privacy and usage management.
โข ImageCreator (on-device, non-UI API) is deprecated; all generation now goes through the sheet-based API running on Private Cloud Compute
โข New photorealistic and expanded style options added, including an externalProvider style (e.g. ChatGPT) configurable by the user
โข ImagePlaygroundOptions now supports explicit size/aspect ratio via .closest(to:), preselected styles, and personalization toggling
โข onAdaptiveImageGlyphCreation callback added for emoji-style outputs returning NSAdaptiveImageGlyph for inline text embedding
โข Instantly add AI image generation to your app with a single view modifier โ no API keys, no server setup, no usage-limit UI to build
โข Supports photorealistic, illustration, sketch, animation, and emoji styles plus configurable aspect ratios, so generated images fit your UI natively
โข Deprecated ImageCreator means apps using the old on-device API must migrate to the new sheet API to maintain functionality
Shows how to present the Image Playground sheet seeded with app context, configure style and aspect ratio options, and handle the resulting image URL โ including a graceful fallback when image generation is unavailable.
import SwiftUIimport ImagePlaygroundโ// Pre-iOS 27: Used the now-deprecated ImageCreator API for on-device generationโstruct LegacyPostcardEditorView: View {โ @State private var generatedImage: Image?โ @State private var isGenerating = false+struct PostcardEditorView: View {+ @Environment(\.supportsImageGeneration) private var supportsImageGeneration+ @State private var showPlayground = false+ @State private var generatedImageURL: URL?+ let cardTheme = "cherry blossoms"+ let cardMessage = "Wishing you a beautiful spring filled with joy and peace."+var body: some View {VStack(spacing: 24) {โ if let image = generatedImage {โ imageโ .resizable()โ .scaledToFill()โ .frame(width: 300, height: 200)โ .clipShape(RoundedRectangle(cornerRadius: 16))+ if let url = generatedImageURL {+ AsyncImage(url: url) { image in+ image+ .resizable()+ .scaledToFill()+ } placeholder: {+ ProgressView()+ }+ .frame(width: 300, height: 200)+ .clipShape(RoundedRectangle(cornerRadius: 16))} else {RoundedRectangle(cornerRadius: 16).fill(.secondary.opacity(0.2)).frame(width: 300, height: 200).overlay(Text("No image yet").foregroundStyle(.secondary))}โ Button(isGenerating ? "Generating..." : "Generate Card Art") {โ Task { await generateImage() }+ if supportsImageGeneration {+ Button("Generate Card Art") {+ showPlayground = true+ }+ .buttonStyle(.borderedProminent)+ .imagePlaygroundSheet(+ isPresented: $showPlayground,+ concepts: [+ .text(cardTheme),+ .extracted(from: cardMessage)+ ],+ options: ImagePlaygroundOptions {+ ImagePlaygroundSize.closest(to: CGSize(width: 1200, height: 800))+ ImagePlaygroundGenerationStyle(+ default: .illustration,+ allowed: [.illustration, .sketch, .animation]+ )+ ImagePlaygroundPersonalization.enabled+ }+ ) { imageURL in+ // URL is temporary โ copy it to persistent storage+ let destination = FileManager.default+ .temporaryDirectory+ .appendingPathComponent(UUID().uuidString + ".png")+ try? FileManager.default.copyItem(at: imageURL, to: destination)+ generatedImageURL = destination+ }+ } else {+ Text("Image generation not available on this device.")+ .foregroundStyle(.secondary)+ .multilineTextAlignment(.center)+ .padding()}โ .disabled(isGenerating)โ .buttonStyle(.borderedProminent)}.padding()+ .navigationTitle("Postcard Editor")}+}โ @MainActorโ private func generateImage() async {โ isGenerating = trueโ defer { isGenerating = false }โ do {โ // ImageCreator is deprecated in iOS 27โ let creator = ImageCreator()โ let request = ImageCreationRequest(โ content: [.text("cherry blossoms, spring celebration")]โ )โ for try await result in creator.images(for: request) {โ if let cgImage = result.cgImage {โ generatedImage = Image(cgImage, scale: 1, label: Text("Generated"))โ breakโ }โ }โ } catch {โ print("Image generation failed: \(error)")โ }+#Preview {+ NavigationStack {+ PostcardEditorView()}}
ImageCreator is deprecated โ migrate to the new sheet API. The completion URL is temporary; save it before the sheet session ends. Emoji style fires a separate onAdaptiveImageGlyphCreation closure returning NSAdaptiveImageGlyph, not a URL. supportsImageGeneration environment value must be checked to gracefully fall back on unsupported devices.
Requires Apple Intelligence-capable device; depends on Private Cloud Compute; available only in supported languages/regions with image generation enabled in Settings; iCloud+ increases usage limits
More iOS 27 APIs land every week.
Get notified when new capabilities are published โ no noise, just signal.