I've created a Snippet for my iOS app which I want to be able to run from the LockScreen via a Shortcuts widget.
All works fine except when I run the shortcut and the App Snippet appears, it doesn't always render the SwiftUI view in the same way. Sometimes the width boundaries are respected and sometimes not.
I've tested this on iOS 26.1 and iOS 26.2 beta 3
I think this is a bug but it would be great if anyone could see what I might be doing wrong if it's not.
Incase it is a bug I've filed a feedback (FB21076429) and I've created a stripped down sample project showing the issue and added screenshots showing the issue.
Basic code to reproduce issue:
// Intent.swift
// SnippetBug
import AppIntents
import Foundation
import SwiftUI
struct SnippetEntryIntent: AppIntent {
static let title: LocalizedStringResource = "Open Snippet"
static let description = IntentDescription("Shows a snippet.")
// Don’t open the app – stay in the snippet surface.
static let openAppWhenRun: Bool = false
func perform() async throws -> some ShowsSnippetIntent {
.result(snippetIntent: TestSnippetIntent())
}
}
struct TestSnippetIntent: SnippetIntent {
static let title: LocalizedStringResource = "Snippet Intent"
static let description = IntentDescription("Action from snippet.")
@MainActor
func perform() async throws -> some IntentResult & ShowsSnippetView {
.result(view: SnippetView(model: SnippetModel.shared))
}
}
@MainActor
final class SnippetModel {
static let shared = SnippetModel()
private init() {
}
}
struct SnippetView: View {
let model: SnippetModel
var body: some View {
HStack {
Text("Test Snippet with information")
Spacer()
Image(systemName: "heart")
}.font(.headline)
}
}
struct Shortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: SnippetEntryIntent(),
phrases: [
"Snippet for \(.applicationName)",
"Test Snippet \(.applicationName)"
],
shortTitle: "Snippet",
systemImageName: "barcode"
)
}
}
You also need these lines in your main App entry point:
import AppIntents
@main
struct SnippetBugApp: App {
init() {
let model = SnippetModel.shared
AppDependencyManager.shared.add(dependency: model)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
This is correct
This is incorrect