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?
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
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?
在执行完 INIntent 或者AppIntent的Shortcuts后,刷新 WidgetKit桌面小组件
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"
)
}
}
Description
The Shortcut Automation Trigger Transaction frequently times out, ultimately causing the shortcut automation to fail. Please see the attached trace for details.
Additionally, the Trigger is activated even when the Transaction is declined.
Details
In the trace I see the error:
[WFWalletTransactionProvider observeForUpdatesWithInitialTransactionIfNeeded:transactionIdentifier:completion:]_block_invoke Hit timeout waiting for transaction with identifier: <private>, finishing.
Open bug report: FB14035016
Hello. I am having trouble trying to create a control in control center view that opens a specific view in my app using AppIntents (iOS18 )and WidgetKit, can someone help me please? I feel like the original videos and documentations are incomplete.
Hi All,
requirement - "Search (placeholder) in (myApp)".
When user speaks this strings, Siri should open the app and pass the placeholder.
This worked for me only when i used an AppEnum (with specific defined set) with AppEntity.
I want the placeholder to be dynamic and not defined via the AppEnum.
Have observed this feature working fine with Youtube, Spotify & Whatsapp apps.
Is there anything else that these app add specifically to make this work. ?
Also in these app's Siri settings, there is a toggle named - 'Use with Ask Siri'.
Could someone please help in understanding, how this option is enabled ?
My app is an outdoor exercise tracking app that allows you to start exercising from the Control widget。
I want to prompt the user with an AppIntentError.PermissionRequired.location error when the user doesn't authorize Core Location permissions.
When I throw error in the Intent, tap the Control widget doesn't do anything and doesn't give the user any indication of what's happening
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.
XCode Version 16.0 (16A242d)
iPhone 12 - iOS 18 (22A3354)
Macbook Air M1 - Sonoma 14.6.1
I am currently working on building Control Buttons for our app and I have consistently run into the same issue:
Unknown NSError The operation couldn’t be completed. (LNActionExecutorErrorDomain error 2018.)
This error can be found in the following posts:
Apple Developer Forums - Post 1
Apple Developer Forums - Post 2
Apple Developer Forums - Post 3
StackOverflow - Post 4
Github - Post 5
I've tried every single solution recommended within these posts, however nothing has worked successfully so far.
Additionally, I've tried the using .widgetUrl() on the Label() within the ControlWidgetButton like so:
ControlWidgetButton(action: JournalControlIntent()) {
Label("Open App", systemImage: "pencil.line")
.widgetURL(URL(string: "app://control/page"))
}
But this did not work either.
Using the recommended approach to open the app as seen here:
https://developer.apple.com/documentation/widgetkit/creating-controls-to-perform-actions-across-the-system#Open-your-app-with-a-control
simply won't work since we have a Flutter app with deep linking setup. Meaning the only option is launching either a deep link or universal link. Our URL scheme is setup correctly since it's currently working for our iOS Widgets & Shortcuts(which use widgetURL & openURL).
In Post 3, the accepted answer mentions that the control file must have the Target Membership with the App and Widget Targets to work. When I try using this solution the build fails without any errors(until you run it in VSCode where there are many errors about Derived Data - Deleting the derived data doesn't fix this error)
I'm wondering if I have added the Control Widget to the incorrect folder within my XCode project? Since if you use the approach of creating a Control through XCode(File > New > Target > Widget Extension > "Include Control" > Next) it creates a top level directory in the project similar to a Stickers or Watch extension.
My Control Widgets currently reside in the [App] Widgets > Control Buttons > Control Button.swift. It's then added to my main widget definition(App Widget > App_Widget.swift):
@main
struct App_Widget: WidgetBundle {
var body: some Widget {
App_Widget() // works
App_Widget_One() // works
if #available(iOSApplicationExtension 18.0, *) {
ControlButtonOne() // does not open app
ControlButtonTwo() // does not open app
}
}
}
Thank you for your help and time!