Share intents from within an app to drive system intelligence and show the app's actions in the Shortcuts app.

Posts under Intents tag

88 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Localized App Shortcuts phrases don't work with AppIntents consumed from a Framework
Imagine we have an Xcode workspace containing two projects: MyLibrary.xcodeproj holding a framework target MyShortcutsApp.xcodeproj holding an app target which consumes MyLibrary framework Both targets define App Intents and the ones from MyLibrary are exposed via AppIntentsPackage accordingly. When trying to wrap the App Intent from framework as App Shortcut and passing localized AppShortcutPhrases I do see the following compile error: ".../Resources/de.lproj/AppShortcuts.strings:11:1: error: This AppShortcut does not map to a known action (MyLibraryIntent specified). (in target 'MyShortcutsApp' from project 'MyShortcutsApp')" If I use the same localized App Shortcut phrases for an App Intent which is locally defined in the app target, everything works fine and also if I use the framework-provided App Intent in and App Shortcut without passing any localized phrases. This is happening with Xcode 16.0 (16A242d), with 16.1 (16B40) and with 16.2 beta 2 (16C5013f). I already raised this issue via FB15701779 which contains a sample project to reproduce and to further analyze the issue. Thanks for any hint on how to solve that. Frank
0
0
84
4d
Shortcuts not appearing in Shortcuts.app
I'm curious if anyone else has figured out why an intent defined in the intents file never seems to appear in the Shortcuts app on MacOS. I'm following the steps outlined in "Meet Shortcuts for MacOS" from WWDC 2021. https://developer.apple.com/videos/play/wwdc2021/10232 I build and run my app, launch Shortcuts, and the intent I defined refuses to show up! There's one caveat - I allowed Xcode to update to 16.1, and mysteriously the intent became available in Shortcuts.app. When I went to add a second intent, I see the same as above - it simply never shows up in Shortcuts.app. I have a few intents I'd like to write/add, but this build/test cycle is really slowing me down. This app is a completely fresh Swift-AppKit app, I've never archived it, so there shouldn't be more than one copy on disk. I have also cleaned the build folder, restarted Xcode, restarted Shortcuts, restarted my machine entirely... Anyone see this before and find a workaround? Any advice on how to give Shortcuts.app a kick in the rear to try and find my second intent?
0
0
57
1w
INPlayMediaIntentHandling, Unable to Trigger App to Play Specific Podcast
I have an app that's capable of playing podcasts via Siri requests, e.g. "Hey Siri, play [Podcast Name]". I’m using INPlayMediaIntentHandling, that is, the SiriKit domain intents, as opposed to the newer AppIntents framework for its ability to select my app for audio playback without the need to specify the name of the app in the user's request to Siri. This works great overall for the many podcasts I’ve tested the app with, with the exception of one. There's a podcast called "The Headlines", and I when I test the app with the request "Hey Siri, play The Headlines", my app is never selected. Instead, Apple Podcasts begins playback of a show called "NPR News Now". Oddly, if the Apple Podcasts app is deleted, my app will still not be selected by the system, and instead, Siri responds with "I don’t see an app for that. You’ll need to download one" with a button to open the App Store. Additionally, if I do add the app name to the request using this style of intent, Siri responds with "[App Name] hasn’t added support for that with Siri." However, I’d still like to accomplish this without requiring the app name in the Siri request. There's nothing complex in my setup: The target declares one supported intent, INPlayMediaIntent, with "Podcasts" selected as a supported media category. The Siri entitlement is enabled. My INSiriAuthorizationStatus is .authorized. My intent handler is specified in my AppDelegate as follows: func application(_ application: UIApplication, handlerFor intent: INIntent) -> Any? { return IntentHandler.shared } My intent handler is simple: final class IntentHandler: NSObject, INPlayMediaIntentHandling { static let shared = IntentHandler() func handle(intent: INPlayMediaIntent) async -> INPlayMediaIntentResponse { print("IntentHandler: processing intent: \(intent)") /** code to start playback based on information found in `intent` **/ } When requesting Siri to "Play The Headlines", my handler code is not called at all. For all other supported shows, the print statement executes, and playback begins as expected. Is there any way I can get my app to be selected instead of Apple Podcasts for this request?
1
0
123
2w
Issue with Siri Not Displaying Prompt in App Intent
Hello everyone, I'm currently working on an App Intent for my iOS app, and I’ve encountered a frustrating issue related to how Siri prompts for a category selection. Here’s an overview of what I’m dealing with: extension Category: AppEntity, @unchecked Sendable { var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(name)") } static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Category") typealias DefaultQueryType = ShortcutsCategoryQuery static var defaultQuery: ShortcutsCategoryQuery = ShortcutsCategoryQuery() } struct ShortcutsCategoryQuery: EntityQuery { func entities(for identifiers: [String]) async throws -> [Category] { let context = await ModelContext(sharedModelContainer) let categories = try CategoryDataProvider(context: context).getItems() return categories.filter { identifiers.contains($0.id) } } func entities(matching string: String) async throws -> [Category] { return try await suggestedEntities() } func suggestedEntities() async throws -> [Category] { let context = await ModelContext(sharedModelContainer) do { let categories = try CategoryDataProvider(context: context).getItems() if categories.isEmpty { print("No categories found.") } return categories.map { category in Category( id: category.id, name: category.name, stringSymbol: category.stringSymbol, symbol: category.symbol, stringColor: category.stringColor, color: category.color ) } } catch { print(error) return [] } } } The issue arises when I use Siri to invoke the intent. Siri correctly asks me to select a category but does not display any options unless I said something that Siri recognized, like "Casa(House) or *****(Test)" in portuguese. Only then does it show the list of available categories. I would like the categories to appear immediately when Siri asks for a selection. I've already tried refining the ShortcutsCategoryQuery and debugging various parts of my code, but nothing seems to fix this behavior.
1
0
185
2w
AppIntentTimelineProvider "func timeline(for" is called twice after a widget button triggers an AppIntent Perform
I'm adding widget interactivity to my home screen widgets via buttons and AppIntents, but running into some interesting behavior the way the timeline is reloaded after. I'm following this guide from Apple https://developer.apple.com/documentation/widgetkit/adding-interactivity-to-widgets-and-live-activities And the widget is guaranteed to be reloaded when a button pressed with an intent, But whenever the AppIntent is done with the perform action, the widget timeline is always reloaded twice. It's also interesting to note that both reloads happen after the perform method. If you add a 10 second sleep in the perform, nothing happens for 10 seconds, then both reloads happen. This issue with this is 2-fold. calculating and rendering the entire widget timeline can be Networking and DB intensive operations, so I would ideally like to avoid doing all the work twice and save the users battery and processing. The even worse issue, sometimes data on the server changes in between the split second duplicate widget timeline reloads, causing the widget to flash one state, then update to another a second later which is not a good user experience. I have a sample project which shows the issue and is very easy to reproduce. The widget simply keeps track of the number of reloads. To reproduce: Add the widget to the homescreen Press the refresh button, and observe the timeline refresh count always goes up by 2. I've filed a Feedback and attached the sample project and screen recording for anyone to reproduce. FB15595835
1
0
311
2w
AppDependcy in Widgets Extension
I am trying to get Controls working using AppIntents. My Intents make use of @Dependency, which get set up during application launch using AppDependencyManager.shared.add { ... }. When the app has been launched, my Controls work fine. However, when the app gets killed using the app switcher or by the system, my Controls cease to work. Checking in Console.app, I found the following: PROGRAMMING ERROR: Failed to retrieve dependency of type {my dependency}. Please register your dependency with AppDependencyManager before performing a dependent intent. My intents use openAppWhenRun = true, so I don't understand why the dependencies are not registered when running the Intent. Alternatively, I would like to know how to register AppDependencies in a Widgets Extension.
0
0
147
3w
EntityQuery defaultResult is not called again when new widgets are added. Shows stale data.
I'm converting my app to use the new AppIntent system in the widgets from the old custom intent based system. I'm trying to implement defaultResult in my EntityQuery, so the widget can be ready to go as soon as it's added to the home screen. https://developer.apple.com/documentation/widgetkit/making-a-configurable-widget https://developer.apple.com/documentation/appintents/uniqueappentityprovider/defaultresult() But the weird behavior is that defaultResult seems to be called once when the first widget is added to a home screen, and shows the correct data, but then the defaultResult method is never called again when subsequent widgets are added. It just uses the result from when the first widget was added. This especially causes issues because then a user will delete the item that the first widget was referencing, but adding new widgets still try to refer to the old AppEntity that no longer exists, even though "entities(for " returns nil for those IDs to signify that item no longer exists. I would have assumed defaultResult would get called every time a new widget is added, but haven't seen anyone else complain about this. Has anyone seen this issue before or have any advice?
3
1
233
3w
Migrating Widgets from SiriKit Intents to AppIntents Causes widgets to crash with "Unknown extension process"
I'm attempting to migrate my app's Homescreen widget from using the old SiriKit Intent system to the new AppIntent system but running into an issue. This WWDC video is the main source of information I have been going off of. https://developer.apple.com/videos/play/tech-talks/10168/ The problem I'm having is no matter what config I try, as soon as I upgrade to the new app with the AppIntent Widget, all the current widgets on the homescreen stop working, and just show a black screen. Deleting and re-adding the widget to the homescreen from scratch works fine though. I found someone else with a similar issue here on the Apple developer forums, but it didn't look like there was much information or resolution. https://developer.apple.com/forums/thread/759751 https://feedbackassistant.apple.com/feedback/14678285 I used XCode's built in Intent migration UI to create the new CustomIntentMigratedAppIntent which should help migrate the old widgets to the new system. I also double-checked all the names and variable types, and the automatically generated file seems to be correct. I even went ahead and created a brand new empty app with the same app and extension bundle id, and made a hard coded widget which contains the migrated intents, just to make sure nothing in my widget or app code is wrong. And even with the empty app with hardcoded views, the widget is still dead after upgrading the app. It almost seems like the widget is getting disassociated from the app. Even though the app has a new name, the old widget will still show the old name, the widget also does not give any option to edit it, only delete it. And on the new app, I am able to attach my debugger to the widget extension process, but no code inside my timeline, intent, or entity seem to ever be called/run. I looked at the Console log while forcing a refresh of the widget, and I've attached the full logs here, and there is a lot in there about it refreshing widgets. SEE LOGS HERE: Tomer_Logs.txt But one line that stands out, is this error which appears every time the old widget is refreshed [com.shemeshapps.MinecraftServerStatus::com.shemeshapps.MinecraftServerStatus.MinecraftServerStatusHSWidget:MinecraftServerStatusHSWidget:-5734839072461827392] Reload failed; 0 retries remaining: ChronoCoreErrorDomain (1) Error Domain=ChronoCoreErrorDomain Code=1 "Unknown extension process" UserInfo={NSLocalizedDescription=Unknown extension process} Any help in greatly appreciated, Either issues you think might be causing this, or any tips on debugging further! Thanks! I've gone ahead and filled a Feedback, as well as submitted a DTS issue, as this is a release blocker. (The feedback contains the new and old project files to allow anyone to reproduce.) FB15531563 DTS case ID: 9677328
3
1
479
1w
xcodebuild fails to build target that links AppIntents.framework once SWIFT_EXEC is specified
Reasoning I am working on a tool that does swift code preprocessing, which is done by a custom script that gets passed as SWIFT_EXEC. This script does some magic and then calls the original swift compiler from /usr/bin/swiftc. I am facing a rather non-common issue. Problem With the release of Xcode 16, for some reason xcodebuild now forcibly does not supply --compile-time-extraction flag to the appintentsmetadataprocessor, if xcodebuild also has a SWIFT_EXEC= argument. (appintentsmetadataprocessor is a tool that is executed automatically by the xcode build system if the app is using App Intents feature). Xcode 15 behaves fine in this regard and always passes --compile-time-extraction flag to appintentsmetadataprocessor (both with or without SWIFT_EXEC). But when the --compile-time-extraction flag is not passed, the appintentsmetadataprocessor fails with an error, making xcodebuild fail as well, essentially making AppIntents unavailable if SWIFT_EXEC build setting is used. Here's how to reproduce the issue: Create a new iOS Xcode project, add AppIntents.framework to the list of linked frameworks, and run xcodebuild SWIFT_EXEC=/usr/bin/swiftc from the project directory. If you're using Xcode 16 you will get a build error: starting appintentsmetadataprocessor export error: At least one halting error produced during export. No AppIntents metadata have been exported and this target is not usable with AppIntents until errors are resolved. error: The operation couldn't be completed. (GeneratorBuildProductExtractor.BinaryScanningError 6.) Alternatively, instead of running xcodebuild, one can add user-defined build setting SWIFT_EXEC=/usr/bin/swiftc to the xcode project target's build settings and build it from xcode, getting the same build failure error. Question The question I am hoping to get an answer or a hint to, is is there any kind of a workaround that would force appintentsmetadataprocessor to still get the --compile-time-extraction argument, when it is launched by the xcodebuild, so the build process completes sucessfully? I also tried passing LM_COMPILE_TIME_EXTRACTION=YES to the xcodebuild, which, according to /Applications/Xcode.app/Contents/SharedFrameworks/XCBuild.framework/Versions/A/PlugIns/XCBBuildService.bundle/Contents/PlugIns/XCBSpecifications.ideplugin/Contents/Resources/AppIntentsMetadata.xcspec, should enable --compile-time-extraction, however this setting seems to be either ignored or overridden once the SWIFT_EXEC is passed, making it useless. Can this option be injected/enforced? The corresponding issue tracking number is FB15274300 Thank you
0
1
207
Oct ’24
Can I increase the reliability of my app intent updating my widgets?
We have widgets in our app. We're now working on a Live Activitiy with a button calling an app intent. This app intent needs to update our Widgets, and we're seeing semi-great results. When we're updating the widgets from within the app, it works great. Also from geofence triggers it usually works, so we're thinking it might have to do with the "widget update budget"? According to the docs: Cases in which WidgetKit doesn’t count reloads against your widget’s budget include when: The widget performs an app intent, such as when the user taps a button or toggles a switch. But we're not really seeing that. When I run our app from within Xcode, everything runs great all the time and the widget gets updated within milliseconds, but when running the TestFlight version is more spotty. To be clear: This is a button in a live activity, calling an app intent, and in turn, the app intent is calling reloadAllTimelines for our "regular" widgets. The live activity itself always gets updated properly. My question is basically, am I doing something wrong and can I do something to increase the consistency of the widget updating on time? Abbreviated example: final class UserEventIntent: NSObject, LiveActivityIntent { @MainActor func perform() async throws -> some IntentResult { do { let newStatus: (stat: Status, wasSame: Bool) = try await eventHelper.performEvent(status: status) WidgetCenter.shared.reloadAllTimelines() }catch { await WidgetCenterBridge.updateLiveActivityForInProgress(false) } return .result() }
2
0
198
Oct ’24
Siri not picking up app intent
Hello, I have written the following app intent and I can access it via shortcuts. But I can't get Siri to pick it up. I want it to have a dynamic book title (which could be anything) so that the user can say "Add (bookname) to my (app name). I need it to work for ios 17.1 onwards. I have added siri as a capability for my ios app. import AppIntents struct AddBookToReadingListIntent: AppIntent { static var title: LocalizedStringResource = "Add my Book" @Parameter(title: "Book Title", requestValueDialog: "What's the title of the book you want to add?") var bookTitle: String static var parameterSummary: some ParameterSummary { Summary("Add my '\(\.$bookTitle)'") } func perform() async throws -> some IntentResult & ReturnsValue<String> { return .result(value: "Added '\(bookTitle)' to your app") } } struct AppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: AddBookToReadingListIntent(), phrases: [ "Add \(\.$bookTitle) in \(.applicationName)" ], shortTitle: "Add Book to app name", systemImageName: "book" ) } }
2
0
207
4w
How to correctly use AppIntentsExtension with AppShortcutsProvider
I've watched the following 3 WWDC videos on intents and after watching, decided to try and implement an AppIntentsExtension. All my intent action does is run a network request in the background. So it seems like I should be putting it in an AppIntentsExtension instead of in the main app to avoid having to launch the app in the background, and instead have it run directly in the extension. 2022 https://developer.apple.com/videos/play/wwdc2022/10032?time=1620 2023 https://developer.apple.com/videos/play/wwdc2023/10103?time=880 2024 https://developer.apple.com/videos/play/wwdc2024/10134/?time=992 If I just put the intent and shortcut provider code I need inside an AppIntentsExtension, everything works fine except for 1 thing. I have no way to call updateAppShortcutParameters on my AppShortcutsProvider from the main app because it is defined inside the extension. So I have no way to let siri know to re-query my parameterized phrases, and so siri doesnt expose any new phrases when things in the app are updated. So to solve this, I somehow need a way to access the AppShortcutsProvider from within the main app to be able to call updateAppShortcutParameters https://developer.apple.com/documentation/appintents/appshortcutsprovider/updateappshortcutparameters() What is the recommended way to do this? Should I be trying to create a separate framework with the shortcut provider, which is then used by both the main app an extension? I tried doing this but ran into a few build errors. I tried changing the target membership of the AppShortcutsProvider to have the file in the extension, but include both the main app and intent extension, this seems to work, but I am unsure if this is the correct approach.
1
0
276
Oct ’24
@IntentParameterDependency Always Returns nil in iOS 18
The following code works perfectly fine in iOS 17, where I can retrieve the desired dependency value through @IntentParameterDependency as expected. However, in iOS 18, addTransaction always returns nil. struct CategoryEntityQuery: EntityStringQuery { @Dependency private var persistentController: PersistentController @IntentParameterDependency<AddTransactionIntent>( \.$categoryType ) var addTransaction func entities(matching string: String) async throws -> [CategoryEnitity] { guard let addTransaction else { return [] } // ... } func entities(for identifiers: [CategoryEnitity.ID]) async throws -> [CategoryEnitity] { guard let addTransaction else { return [] } // ... } func suggestedEntities() async throws -> [CategoryEnitity] { guard let addTransaction else { return [] } // ... } } Has anyone else encountered the same issue? Any insights or potential workarounds would be greatly appreciated. iOS: 18.0 (22A3354) Xcode 16.0 (16A242d)
2
2
377
Oct ’24