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

177 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

SiriTipView not available on macOS??
According to the (very sparse) documentation, SiriTipView should be available on macOS (13+), but I cannot get it to resolve in XCode -- I also can not verify availability for macOS in the public headers for the AppIntents or the SwiftUI frameworks? Is this simply a mistake in the documentation and it is NOT available on macOS, or am I missing something?
2
0
276
Nov ’23
AppShortcut entities not displayed on spotlight
I have my app that works perfectly fine with app intents and shortcuts in the Shortcut app. I can find my shortcut when I look for my app in spotlight, the only thing that it are not displayed are the suggested entities, even if the param and suggested entities appear on my Shortcut app. I call to the function updateAppShortcutParameters, and I see this error pop up. Could anyone help me understand what I need to do to make it work? Failed to refresh AppShortcut parameters with error: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=159, NSUnderlyingError=0x600005417540 {Error Domain=NSOSStatusErrorDomain Code=-10814 "Unable to find this application extension record in the Launch Services database." UserInfo={_LSFunction=_LSPluginFindWithPlatformInfo, _LSLine=679, NSDebugDescription=Unable to find this application extension record in the Launch Services database., SK=MyDemoAppBinary, IS=false}}, _LSFunction=+[LSBundleRecord bundleRecordWithBundleIdentifier:allowPlaceholder:error:]}
0
1
452
Nov ’23
Shortcut not working on Action Button
I've created a shortcut using an AppIntent and AppIntentProvider. When I try to run the shortcut in the shortcuts app it works well, but if I assign that same shortcut to the new Action Button it shows that something is working (icon shows up on the island) but the perform function is never called. Am I missing something? should I add extra configurations for the action button? thanks
2
2
575
Nov ’23
Shortcuts - how to make it read current time?
I have a shortcuts to read out the weather and my schedule for the day after the alarm is off. However I am UNABLE to find any functions to read out the time. Currently, my shortcuts will perform the following: Hello Name It is sunny/raining today, Currently x degrees celsius. You have N schedules today, from x o'clock to y o'clock, you will be meeting abc "read all my schedule" I want it to read the time before telling me the weather. How could I achieve it in the shortcuts? Thanks a lot.
0
0
309
Nov ’23
WidgetKit with Intent on iOS 17
I have edited the default widget with Intent, but am being hit with the following errors… it runs perfectly fine if I don’t use an Intent in a static widget Could not find an intent with identifier ConfigurationAppIntent, mangledTypeName: Optional("27trainWidgetsConfigExtension22ConfigurationAppIntentV") associateAppIntent(forUserActivity:) Error converting INIntent to App Intent: AppIntents.PerformIntentError.intentNotFound I think it may be something to do with Info.plist?
2
0
1.2k
Nov ’23
Merge my application with a scientific data portal.
Hello, let me introduce myself to you, my name is Maxime and I would like to create artificial intelligence for my research and development needs. I want to use Siri applications with data from a scientific portal established by my university. The APIs are public, however, access to the portal and the network is reserved for university researchers. How can you help me?
0
0
509
Nov ’23
Widget not updated when selecting AppEnum with AppIntents
Hello, I'm new here so I apologize if this is obvious, but I can't seem to figure it out and I couldn't find anything online. I'm trying to select options for a widget using a drop-down, and provide the user with a limited list of options that will never change. I'm using an AppEnum as recommended. However, when selecting an element from the back of the widget, the widget doesn't update. Here's my code: import AppIntents import SwiftUI import WidgetKit struct TestProvider: AppIntentTimelineProvider { func placeholder(in context: Context) -> TestEntry { TestEntry(date: .now, bool: false, str: "Apple", enum1: TestEnum.test1) } func snapshot(for configuration: TestIntent, in context: Context) async -> TestEntry { return TestEntry(date: .now, bool: false, str: "Apple", enum1: TestEnum.test1) } func timeline(for configuration: TestIntent, in context: Context) async -> Timeline<TestEntry> { let testBool = configuration.bool let testStr = configuration.str return Timeline(entries: [ TestEntry( date: .now, bool: testBool, str: testStr, enum1: TestEnum.test1 ) ], policy: .atEnd) } } struct TestEntry: TimelineEntry { let date: Date let bool: Bool let str: String let enum1: TestEnum } struct TestIntent: AppIntent, WidgetConfigurationIntent { static var title: LocalizedStringResource = "Testing" static var description: IntentDescription = .init(stringLiteral: "1, 2, 3, testing") @Parameter(title: "Test bool") var bool: Bool @Parameter(title: "Test string", default: "Apple") var str: String @Parameter(title: "Test enum", default: .test1) var tenum: TestEnum } struct TestWidgetView: View { var entry: TestEntry var body: some View { VStack { Text(entry.str) .foregroundStyle(entry.bool ? .green : .red) Text(entry.enum1 == TestEnum.test1 ? "1" : "2") Text(entry.enum1.rawValue) } .containerBackground(for: .widget) {} } } struct testWidget: Widget { let kind: String = "Test Widget" var body: some WidgetConfiguration { AppIntentConfiguration(kind: kind, intent: TestIntent.self, provider: TestProvider()) { entry in TestWidgetView(entry: entry) } .configurationDisplayName("Test widget") .description("Just a test") .supportedFamilies([.systemSmall]) } } enum TestEnum: String, AppEnum { static var typeDisplayRepresentation: TypeDisplayRepresentation = "Test title 1" case test1 = "1" case test2 = "2" static var caseDisplayRepresentations: [TestEnum : DisplayRepresentation] = [ .test1: "test 1", .test2: "test 2" ] } #Preview(as: .systemSmall) { testWidget() } timeline: { TestEntry(date: .now, bool: false, str: "Apple", enum1: TestEnum.test1) } It's a pretty simple example. The widget updates correctly if I change the boolean or the string, but not if I change the enum selection. What am I doing wrong? Many thanks in advance for the help.
1
0
408
Nov ’23
ITMS-90626: Invalid Siri Support - No example phrase was provided for INSearchForMessagesInten
I've gotten the following error message a few times, does anyone know anything about it? I currently have a WidgetExtension and am suspecting that this is the circle. Your delivery was successful, but you may wish to correct the following issues in your next delivery: ITMS-90626: Invalid Siri Support - No example phrase was provided for INSearchForMessagesIntent in the 'en' language. Please refer to 'https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/global_vocabulary_reference/intent_phrases' ITMS-90626: Invalid Siri Support - No example phrase was provided for INSetMessageAttributeIntent in the 'ko' language. Please refer to 'https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/global_vocabulary_reference/intent_phrases' ITMS-90626: Invalid Siri Support - No example phrase was provided for INSetMessageAttributeIntent in the 'en' language. Please refer to 'https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/global_vocabulary_reference/intent_phrases' ITMS-90626: Invalid Siri Support - No example phrase was provided for INSendMessageIntent in the 'ko' language. Please refer to 'https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/global_vocabulary_reference/intent_phrases' ITMS-90626: Invalid Siri Support - No example phrase was provided for INSearchForMessagesIntent in the 'ko' language. Please refer to 'https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/global_vocabulary_reference/intent_phrases' ITMS-90626: Invalid Siri Support - No example phrase was provided for INSendMessageIntent in the 'en' language. Please refer to 'https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/global_vocabulary_reference/intent_phrases' After you’ve corrected the issues, you can upload a new binary to App Store Connect. Best regards,
0
1
622
Nov ’23
Shortcuts of developed app are not working properly
I am developing an app for my home and I was planning to control my smart home plug with it. So I decided to create two shortcuts: the first one to turn it on, the second one to turn it off. For this, I created an AppIntent and an AppShortcut file: // AppIntent.swift // Runner import AppIntents import Foundation class MerossPostClass{ var request: URLRequest var power_state: String public init(power_state: String) { self.power_state = power_state let url = URL(string: "myurl")! var request = URLRequest(url: url) request.httpMethod = "POST" struct Message: Encodable { let device_type: String let power_state: String let channel: Int } let message = Message( device_type: "mss425f", power_state: power_state, channel: 4 ) let data = try! JSONEncoder().encode(message) request.httpBody = data request.setValue( "application/json", forHTTPHeaderField: "Content-Type" ) self.request = request } public func post(){ let task = URLSession.shared.dataTask(with: self.request) { data, response, error in let statusCode = (response as! HTTPURLResponse).statusCode if statusCode == 200 { print("SUCCESS") } else { print("FAILURE") } } task.resume() } } var activateMeross = MerossPostClass(power_state: "ON") var deactivateMeross = MerossPostClass(power_state: "OFF") @available(iOS 17, *) struct ActivateMagSafeIntent: AppIntent { static let title: LocalizedStringResource = "Activate MagSafe" func perform() async throws -> some IntentResult { activateMeross.post() return .result() } } @available(iOS 17, *) struct DeactivateMagSafeIntent: AppIntent { static let title: LocalizedStringResource = "Deactivate MagSafe" func perform() async throws -> some IntentResult { deactivateMeross.post() return .result() } } // // AppShortcut.swift // Runner import Foundation import AppIntents @available(iOS 17, *) struct ActivateMagSafeShortcuts: AppShortcutsProvider { @AppShortcutsBuilder static var appShortcuts: [AppShortcut] { AppShortcut( intent: ActivateMagSafeIntent(), phrases: ["Activate MagSafe"] ) AppShortcut( intent: DeactivateMagSafeIntent(), phrases: ["Deactivate MagSafe"] ) } } With this Code I can add the shortcuts to the shortcuts app. Problem As long as my device is attached to the debugger, everything is working just fine and I am able to control my smart plug with the shortcuts. But after I detached my phone from the debugger, the shortcuts are only working every second run. After every other run, I get an iOS error message like 'Couldn't Communicate with a helper application' or 'App was terminated unexpectedly'. Is there anybody who has been facing the same issue or has any idea why this is happening? Thanks in advance!
0
0
560
Oct ’23
App Intents get "App" as a parameter (SwifUI with IOS 17.0)
Hello, I have a question regarding app Intents. I have a simple App Intent and it is working as expected (I can see it in shortcuts and the action shows a phrase and opens my app). I would now want to ask the user for an "App" parameter, that would be any app the user has downloaded on his iPhone. Here my example intent: struct SayPhraseIntent: AppIntent { static var title: LocalizedStringResource = "See a text." static var description = IntentDescription("Just says whatever text you type in.") @Parameter(title: "Text") var text: String? func perform() async throws -> some ProvidesDialog { guard let providedText = text else { throw $phrase.needsValueError("What text do you want to see?") } return .result(dialog: IntentDialog(stringLiteral: providedText)) } } An example of a shortcut that asks this is I have seen some apps do it so it must be possible, but I cannot find anywhere the Type of the @Parameter I would need to get that from a user through the shortcut app. Any help or suggestions would be appreciated.
0
0
439
Oct ’23
How to make IntentFile work like the parameter in Show Result in AppIntents?
In Shortcuts, the Show Result action has two features that I cannot reproduce in my swift code. Show Result can connect to the previous action's result automatically when it's added. In my code, I added inputConnectionBehavior: .connectToPreviousIntentResult to my parameter, but it won't work. @Parameter(title: "input", supportedTypeIdentifiers: ["public.plain-text"], inputConnectionBehavior: .connectToPreviousIntentResult) var input: IntentFile The click of Result slot in Show Result allows users to select variable. In my code, the click of MyParameter will open the FileDialog rather than selecting variables. So in whatever way I tried, I cannot make my action work exactly like the Show Result does.
0
0
314
Oct ’23
Widget AppIntent updates SwiftData container, but App UI does not refresh
I'm using the new interactive widgets to trigger an app intent (tap a widget button, swift data model updates). If I tap the widget while the app is not running, then launch the app, the views (populated by an @Query) will show the correct data. However, if the app is running before tapping the widget button, the app's @Query will not refresh and so the app shows stale data. If I quit the app and relaunch it, or otherwise trigger a refresh of the query, then the view will update. Does anyone have a way to get the app to notice when an App Intent has changed Swift Data values outside of the main app? edit: Reported as FB13278891
3
4
1.3k
Oct ’23
iOS 12 device crashes when using Xcode 15
I use Xcode 15 to build my project. When running my project on iOS 16 or iOS 17, everything works fine. However, I noticed that there were numerous crashes when running on iOS 12 (and some people have reported experiencing similar issues on iOS 13 and iOS 14). Initially, I thought this issue was caused by some third-party SDKs. However, even after removing some of them, the crash stack changed, and no useful information was provided. According to some suggestions, we can add "-ld64" or "-ld_classic" to Other Linker Flags to force old linker usage and try to avoid this issue. However, we encountered a build issue with an error message: "appintentsmetadataprocessor[17431:11345759] missing required '--source-files' file path Command ExtractAppIntentsMetadata failed with a nonzero exit code." Now I am unsure what to do next. Can anyone help?
4
2
2.3k
Oct ’23
A widget using Button(intent:) { } will crash on macOS 13, even after restricting the button to macOS 14 using if #available(macOS 14, *) { }
I have a widget with a button that prints "Hello" to the console when tapped. This button is shown only on iOS 17.x and macOS 14.x, and is supposed to be hidden on lower versions. Platform versions tested: iOS 16.6, iOS 17 beta 7 (21A5319a), macOS 13.4.1 Xcode version used: 15.0 beta 7 (15A5229h). Expected behaviour: The button is hidden on iOS 16.x and macOS 13.x, and shown only on iOS 17 and macOS 14. Observed behaviour: The button is hidden on iOS 16.6. However, on macOS 13.4.1, the widget crashes with this error: dyld[5266]: Symbol not found: _$s7SwiftUI6ButtonV012_AppIntents_aB0E6intent5labelACyxGqd___xyXEtc0dE00D6IntentRd__lufC Referenced from: <3EB03A2B-BF9A-31EC-88B9-B4CF015DD35D> /Users/user/Library/Developer/Xcode/DerivedData/WidgetIntentTest-hfjndspaaxqvyuhgdzlznjikilce/Build/Products/Debug/WidgetIntentTest.app/Contents/PlugIns/WidgetExtension.appex/Contents/MacOS/WidgetExtension Expected in: <0A9F8825-DAF1-39A5-953C-C5ECACDC1B0B> /System/Library/Frameworks/_AppIntents_SwiftUI.framework/Versions/A/_AppIntents_SwiftUI Here's the code: The widget code with the button: import WidgetKit import SwiftUI struct WidgetsEntryView: View { var entry: Provider.Entry @available(iOS 17, macOS 14, *) var button: some View { Button(intent: SayHelloIntent()) { Text("Say hello") } } var body: some View { VStack { Text("Hello there") #if os(iOS) if #available(iOS 17, *) { button } #elseif os(macOS) if #available(macOS 14, *) { button } #endif } //ignore this if on iOS 16 or macOS 13 .widgetBackground(backgroundView: Color.clear) } } The rest of the widget code struct Provider: TimelineProvider { func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date()) } func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { completion(SimpleEntry(date: Date())) } func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { let timeline = Timeline(entries: [SimpleEntry(date: Date())], policy: .atEnd) completion(timeline) } } struct SimpleEntry: TimelineEntry { let date: Date } struct Widgets: Widget { let kind: String = "Widgets" var body: some WidgetConfiguration { StaticConfiguration(kind: kind, provider: Provider()) { entry in WidgetsEntryView(entry: entry) } .configurationDisplayName("My Widget") .description("This is an example widget.") } } @main struct WidgetIntentTestBundle: WidgetBundle { var body: some Widget { Widgets() } } //ignore this if on iOS 16 or macOS 13 extension View { func widgetBackground(backgroundView: some View) -> some View { #if os(iOS) if #available(iOSApplicationExtension 17.0, *) { return containerBackground(for: .widget) { backgroundView } } else { return background(backgroundView) } #elseif os(macOS) return background(backgroundView) #endif } } App Intent import AppIntents import WidgetKit struct SayHelloIntent: AppIntent { static var title: LocalizedStringResource = "Say Hello" static var description = IntentDescription("prints hello to the console.") func perform() async throws -> some IntentResult { print("Hello") return .result() } } The app's ContentView struct ContentView: View { var body: some View { VStack { Text("Hello World") } .padding() } } Is anyone else experiencing this issue? The Button initialiser I'm using is marked as available on macOS 13, so I don't see a reason why the widget would crash with that error (which I understand is because it can't find the Button code in SwiftUI on macOS 13. For what it's worth the widget doesn't crash and works as expected when built using Mac catalyst 16. Any help is welcome!
2
0
1.1k
Oct ’23
Interaction donation failed
I have just added simple intent with deployment target 12.4. Facing following issue, but shortcut is available. Interaction donation failed: Error Domain=IntentsErrorDomain Code=1901 "Cannot donate interaction with intent that has no valid shortcut types: <INInteraction: 0x2833a7600> { intent = <INIntent: 0x2825b2880> { }; dateInterval = <_NSConcreteDateInterval: 0x2810414a0> (Start Date) 2023-10-12 05:17:03 +0000 + (Duration) 0.000000 seconds = (End Date) 2023-10-12 05:17:03 +0000; intentResponse = ; groupIdentifier = ; intentHandlingStatus = Unspecified; identifier = 2D9C54D2-4D25-4F24-82AE-E73DB875C662; direction = Unspecified; } for intent <PlaceOrderIntent: 0x2825b6400> { stockName = ; }" UserInfo={NSLocalizedDescription=Cannot donate interaction with intent that has no valid shortcut types: <INInteraction: 0x2833a7600> { intent = <INIntent: 0x2825b2880> { }; dateInterval = <_NSConcreteDateInterval: 0x2810414a0> (Start Date) 2023-10-12 05:17:03 +0000 + (Duration) 0.000000 seconds = (End Date) 2023-10-12 05:17:03 +0000; intentResponse = ; groupIdentifier = ; intentHandlingStatus = Unspecified; identifier = 2D9C54D2-4D25-4F24-82AE-E73DB875C662; direction = Unspecified; } for intent <PlaceOrderIntent: 0x2825b6400> { stockName = ; }}
0
0
213
Oct ’23
Interactive widgets should prevent repeated triggering of AppIntent
Hello everyone! I've found that on the current iOS 17.0/17.1, the Button with an AppIntent within a widget can be tapped at a high frequency. Even if the AppIntent triggered by the first tap has not finished executing, the user can still trigger the AppIntent again. This can lead to repeated or accidental operations by the user. Since there is already an invalidatableContent() API, I think the system should know when an AppIntent has not finished executing. I suggest that in this state, the system should not accept repeated taps from the user. This way, the behavior and appearance of the button would be consistent.
1
0
576
Oct ’23
Persist AppIntent after Force Quit?
I have implemented an AppIntent in my app with the purpose of allowing users to set up an automation within the Shortcuts app that runs based on a boolean value in my app. It works well normally, but I've found that if my app is force quit, the Shortcut no longer works (presumably because it can't fetch the value of the boolean from my app anymore). Does anyone know how to persist this value so that the Shortcut will work regardless of whether my app is open in the background? Here is my implementation of the AppIntent: struct my_automation: AppIntent { static var title: LocalizedStringResource = "Automation Name" var isTrue = UserDefaults.standard.bool(forKey: "myVal") func perform() async throws -> some IntentResult { return .result(value: isTrue) } }
1
0
529
Oct ’23