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

Posts under Intents tag

56 Posts
Sort by:
Post not yet marked as solved
6 Replies
6.1k Views
Issue Summary Hi all, I'm working on an Intents Extension for my app, however when I try to run an intent, Xcode pops up the following error: Could not attach to pid: "965" attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.) An image of the error: This only happens when I try debugging the Intent Extension. Running the main app target or another extension target (e.g. notifications) doesn't produce this error. Build Setup Here are the details of my build setup: Mac Mini M1 Xcode 13 Building to iPhone 11 Pro Max, iOS 15.0.2. I've also tried building to my iPad Pro 12.9 w/ iOS 15.1 and hit the same issue. Things I've tried: Make sure "Debug executable" is unchecked in the scheme I've tried changing the Launch setting to "Automatic" and "Wait for the executable to be launched" I've made sure to run sudo DevToolsSecurity -enable on my mac Rebooted iPhone devices + mac mini Uninstalled / reinstalled the app Deleted derived data Removing / reinstalling the development certs in my keychain --> this actually seemed to work initially, but then the problem came back and now it doesn't work anymore. Console Logs I've looked at the console logs while this error occurs to see if it can shed light on the issue. Here are the ones that seemed notable to me. These logs seem to show that Siri is trying to save / write to a file that it does not have access too. Seems very suspicious error 11:42:38.341470-0800 kernel System Policy: assistantd(31) deny(1) file-read-metadata /private/var/mobile/Library/com.apple.siri.inference error 11:42:38.342204-0800 assistantd failed to save contact runtime data. error=Error Domain=NSCocoaErrorDomain Code=512 "The file “com.apple.siri.inference” couldn’t be saved in the folder “Library”." UserInfo={NSFilePath=/var/mobile/Library/com.apple.siri.inference, NSUnderlyingError=0x100fb03a0 {Error Domain=NSPOSIXErrorDomain Code=5 "Input/output error"}} error 11:42:38.342403-0800 assistantd InferenceError<errorId=crSaveToRunTimeDBFailed file=/Library/Caches/com.apple.xbs/Sources/SiriInference/SiriInference-3100.49.3.1.2/SiriInference/SiriInference/ContactResolver/ContactResolver.swift function=logRunTimeData(runTimeData:config:) line=378 msg=> error 11:42:38.465702-0800 kernel 1 duplicate report for System Policy: assistantd(31) deny(1) file-read-metadata /private/var/mobile/Library/com.apple.siri.inference Looking for "debugserver" entries, like the error suggests, shows these logs: default 11:42:44.814362-0800 debugserver error: [LaunchAttach] MachTask::TaskPortForProcessID task_for_pid(965) failed: ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) default 11:42:44.814476-0800 debugserver 10 +0.011525 sec [03c6/0103]: error: ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0203, pid = 965, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) default 11:42:44.825704-0800 debugserver error: MachTask::StartExceptionThread (): task invalid, exception thread start failed. default 11:42:44.825918-0800 debugserver error: [LaunchAttach] END (966) MachProcess::AttachForDebug failed to start exception thread attaching to pid 965: unable to start the exception thread default 11:42:44.826025-0800 debugserver error: Attach failed default 11:42:44.828923-0800 debugserver error: Attach failed: "Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.". I've also attached the full details of the error below via a text file if it helps. Any help with this issue would be great, and I'm happy to provide more information if needed. Thanks in advance! Xcode Attach Full Error Details
Posted
by
Post marked as solved
2 Replies
903 Views
According to the WWDC19 video (Introducing Parameters for Shortcuts), the parameters are supposed to be resolved in the order you have placed them in the Intents Definition file in Xcode (see timestamp 13:02 through 13:16). In my objective C implementation, this is not happening. I deleted the derivedData and clean the build file, but that did not help. Here is a screenshot of my intents definition parameters: In my implementation, it seems to first process the parameters that do not have "Dynamic Options" check. Then it circles back and works on the ones that have "Dynamic Options". So in my case, it starts with partName, quantity, dimensions, thickness, width, and length. Then it works on partsListName. Furthermore, while the "Disambiguation Prompt" is spoken/written, the "Disambiguation Introduction" is NOT spoken/written. Is this a bug that is causing the parameters to be resolved in the wrong order, or do I need to do something differently to force it to resolve parameters in the order that I need it to go in? And are the "Disambiguation Introduction" supposed to work?
Posted
by
Post not yet marked as solved
4 Replies
1.5k Views
if #available(iOS 16.0, *) {       print("donated")       let intent = BasicIntent()       IntentDonationManager.shared.donate(intent: intent)    } Trying to test if donations work with the new App Intents framework. Donating the shortcut once a user taps a button. The shortcut is not appearing on the lock screen. Everything else is working as expected. The Shortcut is appearing in the Shortcuts App and is working via Siri. In developer settings I have Display Recent Shortcuts -> On Display Donations on Lock Screen -> On Allow Any domain -> On Allow Unverified sources -> On Running iOS 16.2, iPhone 11.
Posted
by
Post not yet marked as solved
3 Replies
1.3k Views
We have a simple AppIntent to let users ask a question in our app. The intent has a single parameter: Prompt which is retrieved by a requestValueDialog. Users have reported that when using Siri, the dialog for "What would you like to ask?" appears, but if they respond with phrases such as "What is the last album by Sting" it just presents the dialog for the prompt again. Testing it, I find that I can reproduce the behavior if I include words like "recent" or "last". Just providing those words in isolation causes the dialog to be presented over and over again. Using the same intent from Shortcuts does not seem to have that limitation, it's only when providing the spoken words for speech recognition. All of that interaction happens outside our code, so I cant see any way to debug or identify why the prompts are being rejected. Is there a different way to specify the @Parameter to indicate the prompt: String could include any arbitrary text - including "recent" or "last" ? My hunch is those words are triggering a system response that is stepping on the requstValueDialog? Here's the basics of how the intent and parameter are setup: struct AskAI: AppIntent { static var title: LocalizedStringResource = "Ask" static var description: IntentDescription = IntentDescription("This will ask the A.I. app") static var openAppWhenRun = false @Parameter(title: "Prompt", description: "The prompt to send", requestValueDialog: IntentDialog("What would you like to ask?")) var prompt: String @MainActor func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView { var response = "" ... response = "You asked: \"\(prompt)\" \n" ... return .result(dialog: "\(response)") } static var parameterSummary: some ParameterSummary { Summary("Ask \(\.$prompt)") } }
Posted
by
Post not yet marked as solved
2 Replies
899 Views
Here is my code : struct NoteIntent: AppIntent { // 3 static var title: LocalizedStringResource = "Write memo" static var openAppWhenRun: Bool = false // 4 @Parameter(title: "Input") var input: String? // 5 @MainActor func perform() async throws -> some ProvidesDialog & IntentResult { guard let providedPhrase = input else { InputViewModel.shared.firstSiriNote = nil throw $input.needsValueError( "Write something") } return .result(dialog: IntentDialog("👏🏻Success!")) } static var parameterSummary: some ParameterSummary { Summary("\(\.$input)") } } My problem is that in Shortcut app input sting parameter only call default keboard,i can't switch third part keyboard or other launguge type
Posted
by
Post not yet marked as solved
2 Replies
516 Views
The LanguagePro app creates two shortcut commands by default, as shown in the figure below: Then there is an entry integrated into siri on the app settings page, as shown in the figure below: After clicking to integrate into siri, it will jump to the Shortcut app of the system, and a new shortcut command adding interface will pop up: After clicking the Add button at the bottom, you can see the shortcut command you just added in the shortcut command. View the details of this newly created shortcut command as shown in the figure below: It can be seen that the newly created shortcut command is an integration of the two predefined shortcut commands. I am very curious, what is the coding process of one-click adding to siri on the app setting page, and how to do it. I used the AppIntents framework of iOS16 to build two shortcut commands, corresponding to the above-mentioned "start conversation" and "continue conversation", but I couldn't find a way to complete the construction of "call robot" Please feel free to enlighten me, thank you!
Posted
by
Post not yet marked as solved
0 Replies
585 Views
I have an app intent like the one below. If the intent is run via siri when the phone is locked then the user is asked to unlock their phone but the shortcut is interrupted. Is it possible to delay opening the app until the result dialog is returned? import AppIntents struct MyIntent: AppIntent { static var title: LocalizedStringResource = "MyApp" static var description = IntentDescription("Captures data") static var openAppWhenRun: Bool = true @Parameter(title: "The Data") var theData: String @MainActor func perform() async throws -> some IntentResult { _ = try await RESTClient.postData(theData: theData) return .result(dialog:"Thank you!") //TODO: Now try to open app } }
Posted
by
Post not yet marked as solved
0 Replies
898 Views
Hello! I'm trying to donate an Intent to iOS using IntentDonationManager, following the methods described in the documentaion. try await IntentDonationManager.shared.donate(intent: MyIntent()) // succeeded However, I'm not seeing any effect of this action anywhere in the system (iOS 17 and 16). I have debugged it on both the simulator and a physical device, and I have also enabled the "Display Recent Shortcuts" toggle in the developer settings, but I still don't see any relevant suggestions appearing. Similarly, the issue also occurs with the old SiriKit framework, where INInteraction.donate(completion:) doesn't seem to have any observable effect. I recall that in iOS 15, the simulator would immediately present the donated Shortcut action on the lock screen and Spotlight page. However, starting from iOS 16 and continuing to the current iOS 17 beta 1/2, I haven't been able to achieve the same behavior using the same code. Another similar report: https://developer.apple.com/forums/thread/723109 So is there any way to test or verify the results of this donation action?
Posted
by
Post not yet marked as solved
1 Replies
674 Views
I have implemented a code that answers my question with Siri, but I want to have a continuous conversation like in ChatGPT app. Can't understand documentation properly to do that. import AppIntents @available(iOS 16.0, *) struct MyAppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: AskQuestionIntent(), phrases: [ "Ask \(.applicationName)", "Ask \(.applicationName) a question" ] ) } } @available(iOS 16, *) struct AskQuestionIntent: AppIntent { static var title: LocalizedStringResource = "Ask question" static var description = IntentDescription("Ask questions directly") @Parameter(title: "Question", requestValueDialog: "What would you like to ask?") var question: String @MainActor func perform() async throws -> some OpensIntent { return .result(opensIntent: self, dialog: IntentDialog(stringLiteral: "some result")) } } Here is How it looks like in ChatGPT: And here is my app: `
Posted
by
Post not yet marked as solved
1 Replies
631 Views
I try to make app intent but i'm beginner at swift. so I watched wwdc vedio : Dive into App Intents. - https://developer.apple.com/videos/play/wwdc2022/10032 But i don't know what does 'Navigator' means at the code. Navigator used together with shared, than navigator is used ad singleton? Does anyone have whole sample code along with thins video? struct OpenCurrentlyReading: AppIntent { static var title: LocalizedStringResource = "Open Currently Reading" @MainActor func perform() async throws -> some IntentResult { Navigator.shared.openShelf(.currentlyReading) return .result() } static var openAppWhenRun: Bool = true }
Posted
by
Post not yet marked as solved
0 Replies
325 Views
Hello, I'm working on the interesting task of blocking settings when I'm using the Parental Control App. Could you advise how to make your Intent visible as Input in IF action?
Posted
by
Post not yet marked as solved
0 Replies
398 Views
I have a SiriKit type in intent definition which include system field 'identifier' and a custom field id. When I try to migrate to AppIntent, since AppEntity conforms to 'Identifiable' I cannot use 'id' in AppEntity, how can I solve this?
Posted
by
Post not yet marked as solved
6 Replies
883 Views
Hi all, I'm working on a really basic counter app as a way to explore SwiftData and have come across some behavior that I don't understand. I have a very simple App Intent that increments a user-specified counter in my app. The intent doesn't throw any errors and correctly updates the CoreData store but, when I switch back to my app from the Shortcuts app (where I'm testing the app intent), the view hasn't updated. Closing and re-opening the app shows the incremented counter value but I'd like to know if it's possible to have my app's UI update when the CoreData store is updated from outside the app without relaunching the whole app. For some brief context, here's my view and the App Intent: struct ContentView: View { @Environment(\.modelContext) private var modelContext @Query private var counters: [Counter] // ... var body: some View { NavigationStack { List { ForEach(counters) { counter in CounterRowItem(counter: counter) } .onDelete(perform: deleteItems) } // ... } } struct IncrementCounterIntent: AppIntent { static var title: LocalizedStringResource = "Increment Counter" @Parameter(title: "Name", optionsProvider: CounterOptionsProvider()) var name: String func perform() async throws -> some IntentResult & ReturnsValue<Int> { let provider = try CounterProvider() guard let counter = try provider.fetchCounters().first(where: { $0.name == name }) else { print("Couldn't find counter with name '\(name)'") return .result(value: 0) } counter.count += 1 try provider.context.save() return .result(value: counter.count) } private final class CounterOptionsProvider: DynamicOptionsProvider { func results() async throws -> [String] { try CounterProvider().fetchCounters().map { $0.name } } } }
Posted
by
Post not yet marked as solved
0 Replies
426 Views
Was watching this latest WWDC 2023 video and had a question. I see about 17:20 in, they mention you can now put the shortcut provider in an app intent extension. https://developer.apple.com/videos/play/wwdc2023/10103/ This works fine by itself and I can see all my shortcuts and use siri, but as soon as I try to call into the extension from the main app in order to trigger updateAppShortcutParameters() or any other code, I get a linker error. Am I doing something obvious wrong? Note, I called it a framework, but it Is just an extension. Cant figure out how I am supposed to be calling this method. Any help is greatly appreciated! https://developer.apple.com/documentation/appintents/appshortcutsprovider/updateappshortcutparameters()?changes=_4_8 https://imgur.com/a/yDygSVJ
Posted
by
Post not yet marked as solved
1 Replies
486 Views
Hi there, I'm trying to use an enum as a @Parameter for my Widget configuration: enum InteractivePlacesWidgetMode: Int, CaseIterable, AppEnum, Comparable, Equatable { typealias RawValue = Int case favourites = 0, recents, nearbyCategory, collections static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(name: LocalizedStringResource("Mode")) static var caseDisplayRepresentations: [InteractivePlacesWidgetMode: DisplayRepresentation] = [ .favourites: DisplayRepresentation(title: LocalizedStringResource("Favorites")), .recents: DisplayRepresentation(title: LocalizedStringResource("Recents")), .nearbyCategory: DisplayRepresentation(title: LocalizedStringResource("Categories")), .collections: DisplayRepresentation(title: LocalizedStringResource("Collections")) ] static func < (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool { lhs.rawValue < rhs.rawValue } static func == (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool { lhs.rawValue == rhs.rawValue } } Then on the ConfigurationAppIntent I would like to show some more option only for specific cases, with the following: struct ConfigurationAppIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Configuration" static var description = IntentDescription("Choose what to show") @Parameter(title: LocalizedStringResource("Show"), default: .favourites) var widgetMode: InteractivePlacesWidgetMode @Parameter (title: "Category") var category: CategoryDetail? static var parameterSummary: some ParameterSummary { When(\.$widgetMode, .equalTo, .nearbyCategory) { Summary { \.$widgetMode \.$category } } otherwise: { Summary { \.$widgetMode } } } } But the widget seems to ignore the When clausole at all. Is this a limitation of the When clausole? Is there something wrong with my approach? I already used that with standard types in previous work and it seems to work quite well. Thanks in advance for your help. c.
Posted
by