App Intents

RSS for tag

Extend your app’s custom functionality to support system-level services, like Siri and the Shortcuts app.

Posts under App Intents tag

192 Posts

Post

Replies

Boosts

Views

Activity

OSLog is not working when launching the app with Siri.
I am implementing AppIntent into my application as follows: // MARK: - SceneDelegate var window: UIWindow? private var observer: NSObjectProtocol? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } // Setup window window = UIWindow(windowScene: windowScene) let viewController = ViewController() window?.rootViewController = viewController window?.makeKeyAndVisible() setupUserDefaultsObserver() checkShortcutLaunch() } private func setupUserDefaultsObserver() { // use NotificationCenter to receive notifications. NotificationCenter.default.addObserver( forName: NSNotification.Name("ShortcutTriggered"), object: nil, queue: .main ) { notification in if let userInfo = notification.userInfo, let appName = userInfo["appName"] as? String { print("📱 Notification received - app is launched: \(appName)") } } } private func checkShortcutLaunch() { if let appName = UserDefaults.standard.string(forKey: "shortcutAppName") { print("🚀 App is opened from a Shortcut with the app name: \(appName)") } } func sceneDidDisconnect(_ scene: UIScene) { if let observer = observer { NotificationCenter.default.removeObserver(observer) } } } // MARK: - App Intent struct StartAppIntent: AppIntent { static var title: LocalizedStringResource = "Start App" static var description = IntentDescription("Launch the application with the command") static var openAppWhenRun: Bool = true @MainActor func perform() async throws -> some IntentResult { UserDefaults.standard.set("appName", forKey: "shortcutAppName") UserDefaults.standard.set(Date(), forKey: "shortcutTimestamp") return .result() } } // MARK: - App Shortcuts Provider struct AppShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: StartAppIntent(), phrases: [ "let start \(.applicationName)", ], shortTitle: "Start App", systemImageName: "play.circle.fill" ) } } the app works fine when starting with shortcut. but when starting with siri it seems like the log is not printed out, i tried adding a code that shows a dialog when receiving a notification from userdefault but it still shows the dialog, it seems like the problem here is when starting with siri there is a problem with printing the log. I tried sleep 0.5s in the perform function and the log was printed out normally try? await Task.sleep(nanoseconds: 500_000_000) // 0.5 seconds I have consulted some topics and they said that when using Siri, Intent is running completely separately and only returns the result to Siri, never entering the Main App. But when set openAppWhenRun to true, it must enter the main app, right? Is there any way to find the cause and completely fix this problem?
2
0
69
3h
App Shortcuts Limitations
I've been implemented App Shortcuts into my apps which are localized for a variety of languages. The WWDC23 "Spotlight your app with App Shortcuts" has been extremely helpful in resolving my localized trigger phrases issue, but before I continue filling out all of the trigger phrases for my application I am concerned about a limitation that was mention in the video and need some additional information about it. The limitations noted in the video at minute mark 21:26 states that: Maximum 10 App Shortcuts (OK) Maximum 1000 trigger phrases... If I have 1 app and 10 shortcuts, and each shortcut only uses (.applicationName), this means I get to have 100 trigger phrases for each shortcut (for the sake of the discussion). What I'm unsure about is when I begin providing localization do the localized triggered phrases count toward the trigger phrase limit? Essentially, for every language I support do I have to drop 1/2 of all of my trigger phrases to stay under the limit? At the moment, my app is supporting 40 languages and I would like to know how localization affects the trigger phrase limit. Thank you!
1
0
84
5h
Side Button Access entitlement not appearing in Xcode capabilities list
Hi everyone, I'm trying to add the Side Button Access entitlement to my voice-based conversational app following the documentation, but I'm unable to find it in Xcode. Steps I followed: Selected my app target in Xcode project navigator Went to the Signing & Capabilities tab Clicked the + Capability button Searched for "Side Button Access" Problem: The "Side Button Access" option does not appear in the capabilities list at all. Environment: I'm developing and testing in Japan (where this feature should be available) Xcode version: Xcode 26.2 beta 3 iOS deployment target: iOS 26.2 Questions: Is there any pre-registration or special approval process required from Apple before this entitlement becomes available? Are there any additional requirements or prerequisites I need to meet? Is this feature already available, or is it still in a limited beta phase? Any guidance would be greatly appreciated. Thank you!
0
0
240
6d
Siri media search unable to provide keyword
Hi, I am developing a music app. We are using siri media search functionality for a while. We recently had a case where siri would not provide keyword for a search. When user speaks "Play Kid songs" (in Turkish, çocuk şarkıları çal), when I debug I see mediaSearch.mediaName is nil. When user speaks "Play Kids" (in Turkish, çocuklar çal) a keyword is given and we can search and play related song. Normally I would think that siri is somehow censoring the word "Kid". But when i try the same voice search in Spotify, I get a children song search result. I've read documentations and searched web but couldnt find any similar experience. What would be the cause, is there an extra setting for this kind of behaviour. What would be the cause or a different capability that Spotify can get a keyword out of this voice search but not us?
0
0
22
6d
Siri can’t place calls while device is locked
Hello, I’m developing a third-party VoIP app called Heyno and trying to support Siri-initiated calls so they behave like WhatsApp / FaceTime, especially from the lock screen. Target behavior From the locked device, the user says: “Hey Siri, call <contact> using Heyno” Expected result: • System CallKit audio-call UI appears. • No “continue in ” sheet, no forced unlock or foregrounding. • Our app handles the VoIP leg in the background via CXProviderDelegate. WhatsApp already does this with: “Hey Siri, call <contact> on WhatsApp” I’m trying to reproduce that behavior for Heyno using public APIs. I have followed the SiriKit + CallKit VoIP docs but cannot get a clean Siri → CallKit → app flow from the lock screen without either: Being forced into .continueInApp (unlock + foreground), or Hitting CallKit transaction errors when starting the call from the app in response to the intent. Current implementation Intents extension (INStartCallIntentHandling) • resolveContacts(for:with:) normalizes to E.164 and returns INPersonResolutionResult.success. • resolveDestinationType → .success(.normal). • resolveCallCapability → .success(.audioCall). Confirm / handle currently: func confirm(intent: INStartCallIntent, completion: @escaping (INStartCallIntentResponse) -> Void) { completion(INStartCallIntentResponse(code: .ready, userActivity: nil)) } func handle(intent: INStartCallIntent, completion: @escaping (INStartCallIntentResponse) -> Void) { completion(INStartCallIntentResponse(code: .ready, userActivity: nil)) } Earlier, I used .continueInApp with an NSUserActivity carrying the normalized number and metadata, but that always produced a “Continue in Heyno” sheet that requires unlock and foreground, which breaks the lock-screen Siri flow. App target – CallKit provider In the app I have CXProvider + CXProviderDelegate, which work correctly when calls are initiated from inside the app: func provider(_ provider: CXProvider, perform action: CXStartCallAction) { let handle = action.handle.value // Start VoIP / WebRTC / LiveKit / Asterisk call here provider.reportOutgoingCall(with: action.callUUID, startedConnectingAt: Date()) provider.reportOutgoingCall(with: action.callUUID, connectedAt: Date()) action.fulfill() } If I construct a CXStartCallAction and submit it via CXCallController.request(...) from the app, CallKit UI appears and our pipeline runs correctly. What I tried and what fails Starting CallKit from the Intents extension Calling CXCallController.request(...) directly from handle(intent:completion:) in the extension always yields: com.apple.CallKit.error.requesttransaction error 1 (unentitled) The extension does not have the CallKit entitlement, and the docs say not to initiate calls from the extension, so this path seems unsupported. Using .continueInApp + NSUserActivity Pattern: • handle(intent:) builds NSUserActivity (activityType = NSStringFromClass(INStartCallIntent.self), title = "Heyno Start Call", userInfo with E.164 handle, etc.). • Returns INStartCallIntentResponse(code: .continueInApp, userActivity: activity). • App receives the activity, then starts CallKit + VoIP. Functionally this works, but iOS always requires unlock + foreground (“Continue in Heyno”), which is not acceptable for a Siri lock-screen call. App group + Darwin notification (extension → app → CallKit) Experiment: • Extension writes the normalized number into an app-group UserDefaults. • Extension posts a Darwin notification. • App (if running) listens, reads the number, and initiates CXStartCallAction + VoIP. Observed: • Works only when the app is already running in the background; a killed app is not woken. • In some states I see CXErrorCodeRequestTransactionError.invalidAction (error 6) if I try to issue a CXStartCallAction while CallKit is already doing something as part of the Siri flow. • Siri sometimes replies “There was a problem with the app,” likely because CallKit rejects the transaction or sees duplicate/conflicting actions. My understanding so far • The Intents extension should resolve/confirm the intent but not start the call. • The source of truth for starting a call should be: Siri → CallKit → app’s CXProviderDelegate.provider(_:perform: CXStartCallAction) • The app then starts the VoIP leg, reports started/connected, and fulfills. Where I am stuck What is not clear is how Siri is supposed to route an INStartCallIntent into CallKit for a third-party VoIP app on a locked device without using .continueInApp. If my extension simply: • resolves the contact, • confirm → .ready, • handle → .ready (no NSUserActivity, no CallKit), I do not see a documented mechanism that causes: “Hey Siri, call <contact> using Heyno” on the lock screen to: • Present a CallKit audio call bound to Heyno, and • Deliver CXStartCallAction to my CXProviderDelegate while the app stays in the background. Questions For third-party VoIP apps today, is it recommended to implement INStartCallIntentHandling at all, or should we rely only on CallKit registration and Siri’s built-in support for “Call with ” (no SiriKit extension)? If an INStartCallIntentHandling extension is still the intended pattern: • Should confirm/handle simply return .ready and never start CallKit or set NSUserActivity? • In that case, is Siri expected to invoke CallKit on our behalf and create a CXStartCallAction targeting our provider, even when the device is locked and the app is not foreground? Is there any supported way for a Siri-triggered third-party VoIP call to start from the lock screen via CallKit without: • using .continueInApp (unlock + foreground), and • starting CallKit directly from the Intents extension (unentitled)? Is there any additional configuration, entitlement, provisioning profile flag, or Info.plist key required so that Siri can map “Call using Heyno” directly to our CallKit provider and background VoIP implementation? Current options: • .continueInApp + NSUserActivity → works, but always requires unlock + app UI. • Start CallKit from the extension → fails with “unentitled” and appears unsupported. • Extension → app-group + notification → app → CallKit → VoIP → fragile, with intermittent CXErrorCodeRequestTransactionError.invalidAction. • Remove the extension and hope Siri/CallKit auto-routes to our provider → unclear if this is supported for third-party VoIP apps or reserved for privileged apps. I would appreciate guidance on the intended architecture for this scenario, and whether the “Siri from lock screen → CallKit UI → background VoIP call” flow is achievable for an App Store VoIP app like Heyno using public APIs only.
0
0
136
1w
App intent with parameter launches app before taking user input
I built a couple of app intents for macOS, which generally work great. However, I'm struggling with configuring an app intent that takes a parameter, so that it doesn't require the app to launch before presenting people with the list of options. If the app is running and I run the intent in Spotlight, I can see the message defined by the intent's parameterSummary and I can select a parameter from the list of entities. If the app is not running, it is launched first and only then the intent message fully populates in Spotlight and allows parameter selection. What I've tried: Support background or deferred mode in the intent. Conformed the entities to IndexedEntity. Conformed the entity query to EnumerableEntityQuery, implementing suggestedEntities and allEntities. Conformed the entity query to EntityStringQuery. Donated the intent to Spotlight on app launch. Donated the entities to Spotlight on app launch, both using indexSearchableItems and indexAppEntities. Not sure if both are required or if the latter is just a more convenient version of the former. Do I have to conform to or implement something else? Do I need to work with an app intent extension? If so, would I put all app intent code into the extension instead of the main app? Is this a system bug I should file?
0
0
29
1w
Snippet Views don't render consistently, width not always respected
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
0
0
38
2w
Visual Intelligence: App Intent Not Found?
I'm making a PoC for Visual Intelligence integration in iOS. It's a very simple setup... the extension will always reply with a couple of static "results" just so I can verify that it's working and figure out how to handle receiving app activation from the Intents framework. The app seems to be registering the VI intent correctly, because I see my app's name in the tab list of providers for search results, but when I select my app, I always get no results. I looked at the console for the moment I'm selecting my app and seeing this error: error 16:37:09.433057-0600 duetexpertd [com.hairlessape.VisualIntelligenceProvider.VIAppIntent] Unable to get connection interface: Error Domain=LNConnectionErrorDomain Code=1100 "Unable to locate `com.hairlessape.VisualIntelligenceProvider.VIAppIntent` for the `com.apple.appintents-extension` extension point" No amount of web searching or AI interrogation has produced any headwind here. I've checked the build product and I can see the VIAppIntent.appex file in the Extensions\ folder of my app bundle. I've triple checked the bundle identifiers, code file membership, installed the app from an IPA, restarted my phone, etc. I cannot get my intent to be queried and it's very frustrating. I've put the PoC project on Github: https://github.com/JoshuaSullivan/VisualSearchForVI
5
0
103
2w
AppShortcutsProvider triggered for unsupported OS
Hi! I have an AppShortcutsProvider that has been marked @available(iOS 17.0, *), because all Intents used within it are only available in iOS 17. So the static var appShortcuts should only be accessible in iOS 17, obviously. Now this code has been released and works fine for iOS 17 users. But I just noticed that around 150 iOS 16 users have crashed in the static var appShortcuts, or more specifically, the defaultQuery of one of the Intents. This should not be possible, as neither the AppShortcutsProvider, nor the Intent is exposed to iOS 16, they are marked as @available(iOS 17.0, *). Any idea why this could happen? Here is the crash log: Crashed: com.apple.root.user-initiated-qos.cooperative 0 libswiftCore.dylib 0x3e178c swift::ResolveAsSymbolicReference::operator()(swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*) 1 libswiftCore.dylib 0x40bec4 swift::Demangle::__runtime::Demangler::demangleSymbolicReference(unsigned char) 2 libswiftCore.dylib 0x408254 swift::Demangle::__runtime::Demangler::demangleType(__swift::__runtime::llvm::StringRef, std::__1::function<swift::Demangle::__runtime::Node* (swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*)>) 3 libswiftCore.dylib 0x3e9680 swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) 4 libswiftCore.dylib 0x3e4d9c swift_getTypeByMangledName 5 libswiftCore.dylib 0x3e50ac swift_getTypeByMangledNameInContext 6 MyApp 0x3f6b8c __swift_instantiateConcreteTypeFromMangledName (<compiler-generated>) 7 MyApp 0x640e3c one-time initialization function for defaultQuery + 146 (IntentAction.swift:146) 8 libdispatch.dylib 0x3eac _dispatch_client_callout 9 libdispatch.dylib 0x56ec _dispatch_once_callout 10 MyApp 0x64109c protocol witness for static AppEntity.defaultQuery.getter in conformance IntentAction + 124 (IntentAction.swift:124) 11 AppIntents 0x15c760 _swift_stdlib_malloc_size 12 AppIntents 0x19dfd4 __swift_destroy_boxed_opaque_existential_1Tm 13 MyApp 0x52dadc specialized ActionIntent.init(action:) + 41 (ActionIntent.swift:41) 14 MyApp 0x52df80 specialized static MyShortcuts.appShortcuts.getter + 17 (MyShortcuts.swift:17)
4
1
1.1k
2w
AppShortcutsProvider limitedAvailability in result builder crash
My team is preparing for iOS 18, and wanted to add intents using assistant schemas that are iOS 18 and above restricted. We noticed that the result builder for AppShortcuts added support for limitedAvailabilityCondition from iOS 17.4 so we marked the whole struct as available from it. The app compiles but writing a check like below inside appShortcuts property a crash will happen in iOS 17.5 runtime. (Removing the #available) is solving this problem. if #available(iOS 18, *) { AppShortcut( intent: SearchDonut(), phrases: [ "Search for a donut in \(.applicationName)" ], shortTitle: "search", systemImageName: "magnifyingglass" ) } We tried out putting the os check above and returning shortcuts in arrays and that both compiles and runs but then AppShortcuts.strings sends warnings that the phrases are not used (This phrase is not used in any App Shortcut or as a Negative Phrase.) because the script that extracts the phrases somehow fails to perform when shortcuts are written like below: static var appShortcuts: [AppShortcut] { if #available(iOS 18.0, *) { return [ AppShortcut( intent: CreateDonutIntent(), phrases: [ "Create Donut in \(.applicationName)", ], shortTitle: "Create Donut", systemImageName: "pencil" ) ] } else { return [ AppShortcut( intent: CreateDonutIntent(), phrases: [ "Create Donut in \(.applicationName)", ], shortTitle: "Create Donut", systemImageName: "pencil" ) ] } } This is very problematic because we can't test out on TF with external users new intents dedicated for iOS 18. We filed a radar under FB15010828
2
5
592
2w
Localization not working for App Intents defined inside Swift Package and used in Widget Extension
Hi there, I’m having trouble with localization for App Intents used in a configurable widget when the intents are defined inside a Swift Package. The intents appear correctly in the widget configuration UI and function as expected, but the localized strings are not displayed. Instead, the widget shows the localization keys themselves. Setup Xcode: 26.1 iOS: 26 The App Intents are used for a configurable widget Intent is located in a Swift Package The Widget Extension depends on the package AppIntentsPackage setup: // In the package public struct MySharedIntentsPackage: AppIntentsPackage {} // In the widget extension import AppIntents import SharedAppIntents struct WidgetIntentsPackage: AppIntentsPackage { static var includedPackages: [any AppIntentsPackage.Type] { [MySharedIntentsPackage.self] } } What I’ve tried I tested several configurations separately to see which setup allows localization to work: Localizing inside the Swift Package Placed a Localizable.xcstrings file inside the Swift Package. Specified .module for the bundle parameter in LocalizedStringResource initializers. → The widget still displayed the localization keys. Localizing inside the Widget Extension Placed a Localizable.xcstrings file inside the Widget Extension target instead of the package. → The widget continued to show the localization keys. Allowing mixed localizations Added CFBundleAllowMixedLocalizations = YES to the Widget Extension’s Info.plist. → No change; the widget still showed the keys. Problem In the WWDC 2025 session “Get to Know App Intents”, it was announced that App Intents would officially support Swift Packages. However, despite following that guidance, here we have a situation where the localizations do not work and only the keys appear in a configurable widget’s configuration UI. When I move the same App Intent code directly into the Widget Extension target, localization works as expected, but not when the intent remains inside the Swift Package. Question Is localization for App Intents defined in Swift Packages officially supported for configurable widgets? If yes: Which bundle does App Intents use to resolve localized strings? Should the .xcstrings file be placed in the package or in the host extension’s bundle? Or is this a current limitation or known issue? Any clarification or workaround would be greatly appreciated. Thank you.
1
0
96
2w
watchOS: AppIntents.IntentRecommendation description ignored when applying a .watchface
When we use AppIntents to configure WidgetKit complications, the description we provide in IntentRecommendation is ignored after applying a .watchface file that includes those intent configurations. In the Watch app, under Complications, the labels shown next to each slot do not match the actual complications on the face—they appear to be the first strings returned by recommendations() rather than the selected intent configuration. Steps to Reproduce Create an AppIntent used by a WidgetKit complication (e.g., .accessoryRectangular). Provide multiple intent recommendations with distinct descriptions: struct SampleIntent: AppIntent { static var title: LocalizedStringResource = "Sample" static var description = IntentDescription("Sample data") @Parameter(title: "Mode") var mode: String static func recommendations() -> [IntentRecommendation<Self>] { [ .init(intent: .init(mode: "A"), description: "Complication A"), .init(intent: .init(mode: "B"), description: "Complication B"), .init(intent: .init(mode: "C"), description: "Complication C") ] } func perform() async throws -> some IntentResult { .result() } } Add two of these complications to a Modular Duo face (or any face that supports multiple slots), each with different intent configurations (e.g., A in one slot, B in another). Export/share the face to a .watchface file and apply it on another device. Open the Watch app → the chosen face → Complications. Expected Each slot’s label in Complications reflects the specific intent configuration on the face (e.g., “Complication A”, “Complication B”), matching what the complication actually renders. Actual The labels under Complications do not match the visible complications. Instead, the strings shown look like the first N items from recommendations(), regardless of which configurations are used in each slot. Notes The complications themselves render correctly on-watch; the issue is the names/labels displayed in the Watch app UI after applying a .watchface. Filed Feedback: FB20915258
3
3
110
2w
Correct SwiftData Concurrency Logic for UI and Extensions
Hi everyone, I'm looking for the correct architectural guidance for my SwiftData implementation. In my Swift project, I have dedicated async functions for adding, editing, and deleting each of my four models. I created these functions specifically to run certain logic whenever these operations occur. Since these functions are asynchronous, I call them from the UI (e.g., from a button press) by wrapping them in a Task. I've gone through three different approaches and am now stuck. Approach 1: @MainActor Functions Initially, my functions were marked with @MainActor and worked on the main ModelContext. This worked perfectly until I added support for App Intents and Widgets, which caused the app to crash with data race errors. Approach 2: Passing ModelContext as a Parameter To solve the crashes, I decided to have each function receive a ModelContext as a parameter. My SwiftUI views passed the main context (which they get from @Environment(\.modelContext)), while the App Intents and Widgets created and passed in their own private context. However, this approach still caused the app to crash sometimes due to data race errors, especially during actions triggered from the main UI. Approach 3: Creating a New Context in Each Function I moved to a third approach where each function creates its own ModelContext to work on. This has successfully stopped all crashes. However, now the UI actions don't always react or update. For example, when an object is added, deleted, or edited, the change isn't reflected in the UI. I suspect this is because the main context (driving the UI) hasn't been updated yet, or because the async function hasn't finished its work. My Question I'm not sure what to do or what the correct logic should be. How should I structure my data operations to support the main UI, Widgets, and App Intents without causing crashes or UI update failures? Here is the relevant code using my third (and current) approach. I've shortened the helper functions for brevity. // MARK: - SwiftData Operations extension DatabaseManager { /// Creates a new assignment and saves it to the database. public func createAssignment( name: String, deadline: Date, notes: AttributedString, forCourseID courseID: UUID, /*...other params...*/ ) async throws -> AssignmentModel { do { let context = ModelContext(container) guard let course = findCourse(byID: courseID, in: context) else { throw DatabaseManagerError.itemNotFound } let newAssignment = AssignmentModel( name: name, deadline: deadline, notes: notes, course: course, /*...other properties...*/ ) context.insert(newAssignment) try context.save() // Schedule notifications and add to calendar _ = try? await scheduleReminder(for: newAssignment) newAssignment.calendarEventIDs = await CalendarManager.shared.addEventToCalendar(for: newAssignment) try context.save() await MainActor.run { WidgetCenter.shared.reloadTimelines(ofKind: "AppWidget") } return newAssignment } catch { throw DatabaseManagerError.saveFailed } } /// Finds a specific course by its ID in a given context. public func findCourse(byID id: UUID, in context: ModelContext) -> CourseModel? { let predicate = #Predicate<CourseModel> { $0.id == id } let fetchDescriptor = FetchDescriptor<CourseModel>(predicate: predicate) return try? context.fetch(fetchDescriptor).first } } // MARK: - Helper Functions (Implementations omitted for brevity) /// Schedules a local user notification for an event. func scheduleReminder(for assignment: AssignmentModel) async throws -> String { // ... Full implementation to create and schedule a UNNotificationRequest return UUID().uuidString } /// Creates a new event in the user's selected calendars. extension CalendarManager { func addEventToCalendar(for assignment: AssignmentModel) async -> [String] { // ... Full implementation to create and save an EKEvent return [UUID().uuidString] } } Thank you for your help.
5
0
167
3w
AppIntents crashes in prod
We implemented AppIntents using EnumerableEntityQuery and @Dependency and we are receiving these crash reports: AppIntents/AppDependencyManager.swift:120: Fatal error: AppDependency of type MyDependency.Type was not initialized prior to access. Dependency values can only be accessed inside of the intent perform flow and within types conforming to _SupportsAppDependencies unless the value of the dependency is manually set prior to access. I can't post the stack because of the Developer Forums sensitive language filter :( but basically it's just a call to suggestedEntities of MyEntityQuery that calls the dependency getter and then it crashes. My understanding was that when using @Dependency, the execution of the intent, or query of suggestedEntities in this case, would be delayed by the AppIntents framework until the dependency was added to the AppDependencyManager by me. At least that's what's happening in my tests. But in prod I'm having these crashes which I haven't been able to reproduce in dev yet. Does anyone know if this is a bug or how can this be fixed? As a workaround, I can avoid using @Dependency and AppDependencyManager completely and make sure that all operations are async and delay the execution myself until the dependency is set. But I'd like to know if there's a better solution. Thanks!
1
0
128
Oct ’25
Siri AppIntent phrasing
When my AppShortcut phrase is: "Go (.$direction) with (.applicationName)" Then everything works correctly, the AppIntent correctly receives the parameter. But when my phrase is: "What is my game (.$direction) with (.applicationName)" The an alert dialog pops up saying: "Hey siri what is my game tomorrow with {app name} Do you want me to use ChatGPT to answer that?" The phrase is obviously heard correctly, and it's exactly what I've specified in the AppShortcut. Why isn't it being sent to my AppIntent? import Foundation import AppIntents @available(iOS 17.0, *) enum Direction: String, CaseIterable, AppEnum { case today, yesterday, tomorrow, next static var typeDisplayRepresentation: TypeDisplayRepresentation { TypeDisplayRepresentation(name: "Direction") } static var caseDisplayRepresentations: [Direction: DisplayRepresentation] = [ .today: DisplayRepresentation(title: "today", synonyms: []), .yesterday: DisplayRepresentation(title: "yesterday", synonyms: []), .tomorrow: DisplayRepresentation(title: "tomorrow", synonyms: []), .next: DisplayRepresentation(title: "next", synonyms: []) ] } @available(iOS 17.0, *) struct MoveItemIntent: AppIntent { static var title: LocalizedStringResource = "Move Item" @Parameter(title: "Direction") var direction: Direction func perform() async throws -> some IntentResult { // Logic to move item in the specified direction print("Moving item \(direction)") return .result() } } @available(iOS 17.0, *) final class MyShortcuts: AppShortcutsProvider { static let shortcutTileColor = ShortcutTileColor.navy static var appShortcuts: [AppShortcut] { AppShortcut( intent: MoveItemIntent() , phrases: [ "Go \(\.$direction) with \(.applicationName)" // "What is my game \(\.$direction) with \(.applicationName)" ] , shortTitle: "Test of direction parameter" , systemImageName: "soccerball" ) } }
3
0
251
Oct ’25
Siri Shortcut extension build cycle
I developed a XCode project using Flutter (v. 3.35.6). The application basically has a IntentExtension to handle intents donation and the related business logic. We decided to go with ShortcutExtension in place of AppIntents because it fits with our app's use case (where basically we need to dynamically donate/remove intents). We have an issue building the project, and it is due to the presence of the IntentExtension .appex file in the Build Phases --> Embed Foundation Extensions. If we remove it , the project builds however the IntentHandling is not invoked in the Shortcuts app. Build issue: Generated error in the console: Cycle inside Runner; building could produce unreliable results. Cycle details: → Target 'Runner' has copy command from '/Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/ShortcutsExtension.appex' to '/Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/PlugIns/ShortcutsExtension.appex' ○ That command depends on command in Target 'Runner': script phase “[CP] Copy Pods Resources” ○ That command depends on command in Target 'Runner': script phase “[CP] Embed Pods Frameworks” ○ That command depends on command in Target 'Runner': script phase “FlutterFire: "flutterfire upload-crashlytics-symbols"” ○ That command depends on command in Target 'Runner': script phase “FlutterFire: "flutterfire bundle-service-file"” ○ That command depends on command in Target 'Runner': script phase “Thin Binary” ○ Target 'Runner' has process command with output '/Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/Info.plist' ○ Target 'Runner' has copy command from '/Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/ShortcutsExtension.appex' to '/Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/PlugIns/ShortcutsExtension.appex' Raw dependency cycle trace: target: -> node: -> command: -> node: /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Intermediates.noindex/Runner.build/Release-quality-iphoneos/Runner.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata -> command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Release-quality:ExtractAppIntentsMetadata -> node: -> command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase10-copy-files -> node: <Copy /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/PlugIns/ShortcutsExtension.appex> -> CYCLE POINT -> command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Release-quality:Copy /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/PlugIns/ShortcutsExtension.appex /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/ShortcutsExtension.appex -> node: -> command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase9--cp--copy-pods-resources -> node: /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/GoogleMapsResources.bundle -> command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Release-quality:PhaseScriptExecution [CP] Copy Pods Resources /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Intermediates.noindex/Runner.build/Release-quality-iphoneos/Runner.build/Script-B728693F1F2684724A065652.sh -> node: -> command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase8--cp--embed-pods-frameworks -> node: /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Products/Release-quality-iphoneos/Runner.app/Frameworks/Alamofire.framework -> command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Release-quality:PhaseScriptExecution [CP] Embed Pods Frameworks /Users/federico.gatti/Documents/comfort-mobile-app/apps/comfort/ios/DerivedData/Runner/Build/Intermediates.noindex/Runner.build/Release-quality-iphoneos/Runner.build/Script-1A1449CD6436E619E61D3E0D.sh -> node: -> command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase7-flutterfire---flutterfire-upload-crashlytics-symbols- -> node: <execute-shell-script-18c1723432283e0cc55f10a6dcfd9e024008e7f13be1da4979f78de280354094-target-Runner-18c1723432283e
1
0
59
Oct ’25
Optional Parameter using WidgetConfigurationIntent
Hi there, I'm adding a new widget using the new WidgetConfigurationIntent which takes a number of parameters, including one which conforms to AppEntity. It is defined as an optional. When the user is configuring the widget, after one of the suggested entities is chosen, there is no way to return to a state where this value is nil. Is this possible? I'd like the user to be able to select "None" for this parameter. For now, I'm using a bool to determine whether the AppEntity parameter is used. Thanks!
2
0
1.1k
Oct ’25
openAppWhenRun = true is wrong
import AppIntents struct MGIntents: AppIntent { static var title = LocalizedStringResource("open app") static var openAppWhenRun: Bool = true func perform() async throws -> some IntentResult & ProvidesDialog { return .result(dialog: "app open") } } struct AppItentsShortcuts:AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(intent: MGIntents(), phrases: ["\(.applicationName) Open app"], shortTitle: "Open app", systemImageName: "fan.desk.fill") } } when use ,error more error。 when i delet openAppWhenRun ,is ok。why? how I can do it? thank you!
3
0
282
Oct ’25
'openAppWhenRun' property causing AppIntentsExtension to fail
import AppIntents struct AddTodoIntent: AppIntent { static var title: LocalizedStringResource = "Add Todo" static var openAppWhenRun: Bool = true func perform() async throws -> some IntentResult & ProvidesDialog { .result(dialog: "New todo added successfully.") } } struct ViewTodosIntent:AppIntent { static var title: LocalizedStringResource = "View Todos" func perform() async throws -> some IntentResult & ProvidesDialog { .result(dialog: "Here are your todos...") } } struct TodoAppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: AddTodoIntent(), phrases: ["\(.applicationName) Add a new todo"], shortTitle: "New Todo", systemImageName: "plus.circle" ) AppShortcut( intent: ViewTodosIntent(), phrases: ["\(.applicationName) Show my todoso"], shortTitle: "Show todos", systemImageName: "plus.app" ) } } when we used, it wrong How did i can do it success?
0
0
51
Oct ’25