I'm returning the following result in one of my AppIntents:
return .result(value: "Done!", dialog: IntentDialog("Speed limit \(speedLimit)"))
With iOS 18.0.1 it was nicely confirming the user the result of their command by saying e.g. "Speed limit 60" and showing it on top of the screen.
With iOS 18.1, it only shows/says "That's done" or "Done" at the bottom of the screen.
Am I missing something that changed in the AppIntents API since iOS 18.1?
App Intents
RSS for tagExtend your app’s custom functionality to support system-level services, like Siri and the Shortcuts app.
Posts under App Intents tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I am working on adding indexing to my App Entities via IndexedEntity. I already, separately index my content via Spotlight.
Watching 'What's New in App Intents', this is covered well but I have a question.
Do I need to implement both CSSearchableItem's associateAppEntity AND also a custom implementation of attributeSet in my IndexedEntity conformance? It seems duplicative but I can't tell from the video if you're supposed to do both or just one or the other.
Hi devs,
my app has control center widgets and interactive widgets, both are using the same app intent to update sharing status (App Group's UserDefault).
When the app is running in the background, control center widget and interactive widgets can be reloaded with correct status. However, if the app is not running in the background, I tap the interactive widget and the interactive widget can reload with correct status but the control center widget can't. Vice versa, the control center widgets can reload with correct status but the interactive widgets can't.
struct ChangeAppStatusIntent: AudioRecordingIntent, CustomIntentMigratedAppIntent, PredictableIntent, LiveActivityIntent, SetValueIntent {
... // data and setup
@MainActor
func perform() async throws -> some IntentResult {
// change the AppGroup data for app status
WidgetCenter.shared.reloadAllTimelines()
ControlCenter.shared.reloadAllControls()
}
}
does any way to fix this issue?
@available(iOS 18.0, *)
@AssistantIntent(schema: .system.search)
struct SearchIntent: AppIntent {
static let title: LocalizedStringResource = "Search <app name redacted>"
static let searchScopes: [StringSearchScope] = [.general]
@Parameter(title: "Criteria")
var criteria: StringSearchCriteria
@MainActor
func perform() async throws -> some IntentResult {
MyDependencyManager.shared.performSearch(with: criteria.term)
return .result()
}
}
// In AppShortcutProvider
AppShortcut(
intent: SearchIntent(),
phrases: [
"Find \(\.$criteria) in \(.applicationName)",
"Search for \(\.$criteria) in \(.applicationName)",
],
shortTitle: "Search <app name redacted>",
systemImageName: "magnifyingglass"
)
The search works when using the Shortcuts app, but not when using Siri. For example if I ask Siri "Search for in " it just does a Google search or prompts me to install the app from the App Store (I am running a debug build via Xcode). I can't get this to work from Spotlight either.
I am using Xcode 16 and running the app on an iPhone 16 with OS 18.2 beta and Apple Intelligence turned on.
What am I doing wrong here? I cannot find any other information about this intent or how to properly set it up and use it.
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
Hello,
I am implementing an App Intent which asks the user for a currency amount:
private func loadAmountList(forNumber number: String) async throws -> [NSDecimalNumber] {...}
@MainActor func perform() async throws -> some IntentResult & ShowsSnippetView {
let list = try await loadAmountList(forNumber: fixedNumber).compactMap {
currencyFormatter.string(from: $0)
}
throw $amount.needsDisambiguationError(among: list, dialog: "app_intent_sim_amount_prompt")
}
If I start this intent from Siri, the attached screenshot is shown, but no matter what I say ("10 EURO", "ten", "10", "10€"...) Siri never understands anything and keep reshowing the dialog over and over again.
If instead I tap any of the choices then the intent execution proceeds currectly.
How can I solve the problem?
Thanks
Hello,
I am implementing an App Intent which shows a confirmation dialog before proceeding with the operation execution.
It works fine when the intent is started from a shortcut, but it always fails when started from Siri: I obtain the error message depicted in the attached screenshot ("An error occurred, try again").
That message appears as soon as the requestConfirmation method is called in the perform method of my App Intent:
try await requestConfirmation(actionName: .do, dialog: "app_intent_sim_confirmation_message") {
SIMRechargeIntentSummaryView(...)
}
...
How can I solve the problem?
Thanks
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.
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?
func handle(intent: INSendPaymentIntent, completion: @escaping (INSendPaymentIntentResponse) -> Void) {
if let _ = intent.payee, let currencyAmount = intent.currencyAmount {
let userActivity = NSUserActivity(activityType: "com.rapipay.nye.test.failure")
userActivity.userInfo = ["amount": Int(truncating: currencyAmount.amount!)]
completion(INSendPaymentIntentResponse(code: .failureRequiringAppLaunch, userActivity: userActivity ))
return
}
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
print("ddddd")
return true
}
this code is perfectly working on simulator and even i fi user userActivity as nil, continue userActivity is called, but on device it is not called
Siri is working, asking for name and amount and handler is also called and opens app but does not pass intent or userActivity
Hey, I was wondering on how to react to the focus mode being turned off inside the FocusFilterIntent. I've successfully managed to call a specific action when the focus is being set, but I now want to deactivate/ react when the focus is being deactivated. How can I achieve something like this?
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
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
https://medium.com/@giulio.caggegi/use-app-intents-with-ios-16-90a341ccbc94
I create a demo according this article,
and add the App Intents in Shortcuts App ,
then add a Scripting "Get text from ***" ,
but the result is Empty,
how could I modify the AppEntity or add which attribute,
so the Scripting "Get text from ***" can get text from the App Intents?
Task {
for await update in LockedCameraCaptureManager.shared.sessionContentUpdates {
switch update {
case .initial(let urls):
print("frank: init \(urls)")
await MainActor.run {
let label = UILabel(frame: CGRect(x: 100, y: 100, width: 100, height: 30))
label.text = "frank test"
label.textColor = .black
UIViewController.getTop().view.addSubview(label)
}
case .added(let url):
print("frank: add \(url)")
case .removed(let url):
print("frank: removed \(url)")
default:
break
}
}
}
why 'case .initial(let urls)': never never be executed? Can some one provide a sample code?
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()
}
Issue
When triggering an App Intent using assistant schemas from Apple Intelligence (voice or text) the App opens without prompting for search criteria.
How to repeat
This can be repeated in the example provided by Apple here: https://developer.apple.com/documentation/appintents/making-your-app-s-functionality-available-to-siri
Download the sample code
Build and run on Xcode 16.1 beta 3
Target iPhone 15 Pro Max on iOS 18.1 beta 7
Trigger Apple Intelligence
Enter prompt: "Search AssistantSchemasExample"
Expected behaviour
Apple Intelligence should prompt the user for the criteria and provide this to the App so that the experience is seamless for the end-user. Otherwise Assistant Intents are nothing more than deep links to search screens.
Notes
The example uses @AssistantIntent(schema: .photos.search) intent.
And I've found the issue is also present in other search intents:
@AssistantIntent(schema: .system.search)
@AssistantIntent(schema: .browser.search)
Questions
Has anyone managed to get the prompt to appear?
Will this only function on iOS 18.2?
I am currently working on integrating an app with Siri, adding support for starting VOIP calls and sending messages. Although it is understood it is recommended to use SiriKit for calling and messaging, I would like to allow users to select a profile to use for calling. As far as I am aware the notion of selecting a profile to call from is not something SiriKit supports, therefore, it was decided to go with App Intents to allow for more control over the parameters utilized to start calls.
After integrating VOIP calling with App Intents, I noticed CallKit is not able to start calls when the App Intent is invoked from the background. I get the following error:
Error Domain=com.apple.CallKit.error.requesttransaction Code=6 "(null)”
This seems to correspond to the CXErrorCodeRequestTransactionError invalidAction. This error only happens when the intent is invoked from the background. Changing the App Intent property openAppWhenRun to true solves the issue as it brings the app to foreground before running the intent.
However, I would like to support starting calls from the background to avoid making users unlock their phones prior to starting a call with Siri to make it a truly hands-free experience. I suspect the desired behavior is possible, most likely with SiriKit, as some famous VOIP calling apps (i.e. WhatsApp, Messenger, etc) exhibit the behavior I described. However, is there any way to start calls from the background with App Intents? Or is the desired behavior something exclusive to SiriKit?
I have pasted three code snippets below that can replicate the issue. At the moment I am on Xcode Version 15.3, macOS Sonoma 14.6.1, and testing on iOS 16.6.1
To demonstrate the issue I have created the following CXProviderDelegate:
class CallManager: NSObject, CXProviderDelegate {
func startCall() {
let callKitProvider = CXProvider(configuration: CXProviderConfiguration())
callKitProvider.setDelegate(self, queue: nil)
let callKitController = CXCallController()
let recipient = CXHandle(type: .generic, value: "Demo Outgoing Call")
let uuid = UUID()
let startCallAction = CXStartCallAction(call: uuid, handle: recipient)
let transaction = CXTransaction(action: startCallAction)
callKitController.request(transaction) { error in
if let error {
print(error)
} else {
print("no errors")
}
}
callKitProvider.reportOutgoingCall(with: uuid, connectedAt: nil)
}
func providerDidReset(_ provider: CXProvider) {
// no-op, not required to demonstrate the issue
}
}
Then, I have a UIViewController that is the only screen of this example app:
class ViewController: UIViewController {
@IBOutlet weak var startCallButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
startCallButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
}
@objc func buttonTapped() {
let manager = CallManager()
manager.startCall()
}
}
As for app intents, I put together a very simple intent to trigger the start of an outgoing call:
struct StartCall: AppIntent {
static var title: LocalizedStringResource = "Start Call"
static var openAppWhenRun = false
func perform() async throws -> some IntentResult {
let manager = CallManager()
manager.startCall()
return .result()
}
}
When the UIViewController is presented and I tap the button to start a call I see the green call banner appear and "no errors" is printed to the console as intended. However, when I open the Shortcuts app and run the app intent, the green banner does not appear and the message Error Domain=com.apple.CallKit.error.requesttransaction Code=6 "(null)” is printed to the console.
I have encountered a problem about AppEntity and AppIntent shortcut. Here is what i have done.
I created some shortcuts use AppShortcutsProvider. Each shortcut created by AppEntity.
I search my app name in spotlight, so these shortcut can be shown in the spotlight.
I don't click the shortcut and back to home screen. Then I delete these shortcuts by modify the Entity.defaultQuery and call AppShortcutsProvider.updateAppShortcutParameters()
Going back to the spotlight, I can see my previous query and result. When I clicked the shortcut, I got an error WFBackgroundShortcutRunnerErrorDomain
Should the spotlight result need to be refreshed when i come back to it?
It is no longer displayed as a target for shortcut app actions.
It was displayed until iOS 17.7.
Tried with iOS 18.0 and 18.0.1 but it does not appear.
Shortcuts created when under iOS 18 work fine.
Only INPlayMediaIntent is supported and is targeted at iOS 15 and above, so no Extension is used and is handled directly in the app.
Is anyone else suffering from the same problem?