My question is similar to https://developer.apple.com/forums/thread/757298?answerId=791343022#791343022 but the solution from there did not help me.
My app sends messages. I need it to do so when a user says to Siri: "Send message with ". When a user says so, Siri shows "Open button and says " hasn't added support for that with Siri".
The code is pretty short and must work, but it doesn't. Could you please help and explain how to add the support mentioned above? How else I can use AppIntent and register the app as one capable to send messages when asked by Siri?
import AppIntents
@main
struct MyAppNameApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
init() {
MyAppNameShortcuts.updateAppShortcutParameters()
Task {
await MyAppNameShortcuts.updateAppShortcutParameters()
}
}
}
struct SendMessageWithMyAppName: AppIntent {
static var title: LocalizedStringResource = "Send message"
static let description = IntentDescription(
"Dictate a message and have MyAppName print it to the Xcode console.")
@Parameter(title: "Message", requestValueDialog: "What should I send?")
var content: String
static var openAppWhenRun = false
func perform() async throws -> some IntentResult {
print("MyAppName message: \(content)")
await MainActor.run {
NotificationCenter.default.post(name: .newMessageReceived, object: content)
}
return .result(dialog: "Message sent: \(content)")
}
}
struct MyAppNameShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: SendMessageWithMyAppName(),
phrases: [
"Send message with \(.applicationName)"
],
shortTitle: "Send Message",
systemImageName: "message"
)
}
}
Automation & Scripting
RSS for tagLearn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I use NSUserAppleScriptTask in my app to call Apple Script method to send Apple Events to Finder and System Events.
The script has been deployed in the folder ~/Library/Application Scripts/{app bundle id}/
I have configured the com.apple.security.automation.apple-events in the .entitlements file, but how to configure com.apple.security.scripting-targets to meet the AppStore review requirements
The existing official documentation is too incomplete to be of much use. If anyone has had similar experience, could you please share?
I'm trying to run sample Trails app from the documentation, unaltered.
When I do the build, I get a
Command ValidateAppShortcutStringsMetadata failed with a nonzero exit code
error. How do I debug this?
I'm trying this on Xcode 16.4.
When my Intents extension resolves an INStartCallIntent and returns .continueInApp while the device is locked, the call does not proceed unless the user unlocks the device. After unlocking, the app receives the NSUserActivity and CallKit proceeds normally.
My expectation is that the native CallKit outgoing UI should appear and the call should start without requiring unlock — especially when using AirPods, where attention is not available.
Steps to Reproduce
Pair and connect AirPods.
Lock the iPhone.
Start music playback (e.g. Apple Music).
Place the phone face down (or cover Face ID sensors so attention isn’t available).
Say: “Hey Siri, call Tommy with DiscoMonday(My app name).”
Observed Behavior
Music mutes briefly.
Siri says “Calling Tommy with DiscoMonday.”
Lock screen shows “Require Face ID / passcode.”
After several seconds, music resumes.
The app is not launched, no NSUserActivity is delivered, and no CXStartCallAction occurs.
With the phone face up, the same phrase launches the app, triggers CXStartCallAction, and the call proceeds via CallKit after faceID.
Expected Behavior
From the lock screen, Siri should hand off INStartCallIntent to the app, which immediately requests CXStartCallAction and drives the CallKit UI (reportOutgoingCall(...startedConnectingAt:) → ...connectedAt:), without requiring device unlock, regardless of orientation or attention availability when AirPods are connected.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
iOS
Siri and Voice
Intents
CallKit
I have a food logging app. I want my users to be able to say something like:
"Hey siri, log chicken and rice for lunch"
But appshortcuts provider is forcing me to add the name of the app to the phrase so it becomes:
"Hey siri, log chicken and rice for lunch in FoodLogApp".
After running a quick survey, I've found that many users dislike having to say the name of the app, it makes it too cumbersome.
My question is:
Is there a plan from apple 2026 so the users can converse with Siri and apps more naturally without having to say the name of the app? If so, is it already in Beta and can you point me towards it?
@available(iOS 17.0, *)
struct LogMealIntent: AppIntent {
static var title: LocalizedStringResource = "Log Meal"
static var description: LocalizedStringResource = "Log a meal"
func perform() async throws -> some IntentResult {
return .result()
}
}
@available(iOS 17.0, *)
struct LogMealShortcutsProvider: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: LogMealIntent(),
phrases: [
"Log chicken and rice for lunch in \(.applicationName)",
],
shortTitle: "Log meal",
systemImageName: "mic.fill"
)
}
}
I’ve developed an automation and shortcut using the iPhone Shortcuts app in IOS 18, something that hasn’t been done before. With support from Apple’s customer service, I was encouraged to bring this idea to life.
The automation’s purpose is to open a specified iOS app, move it to the background, and use a txt database in Folders to ensure uninterrupted data flow and continuous connectivity—especially useful for health apps where wearable devices need consistent, uninterrupted operation and monitoring (e.g., doctor tracking or wearable device connectivity). I would like to share the Automation and the Shortcut with the community.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Health and Fitness
Scripting
Shortcuts
Context
I'm working on a Mail.app plugin. I would like to disseminate plugin via AppStore.
I'm interested in exposing a functionality to user enabling user to choose if plugin should apply to all or selected email account.
My intention is to use AppleScript to get a list of available email accounts and expose the list to the end-user via SwiftUI
Sourcing account information
Apple Script
I'm using the following AppleScript
tell application "Mail"
set accountDict to {}
repeat with acc in accounts
set accName to name of acc
set accEmails to email addresses of acc
set accountDict's end to {accName:accEmails}
end repeat
return accountDict
end tell
The above generates expected results when executed using Script Editor.
Swift Implementation
This is still incomplete but shows the overall plan.
//
// EmailAccounts.swift
import Foundation
enum EmailScriptError: Error {
case scriptExecutionError(String)
}
struct EmailAccounts {
func getAccountNames() -> [String]? {
let appleScriptSource = """
tell application "Mail"
set accountDict to {}
repeat with acc in accounts
set accName to name of acc
set accEmails to email addresses of acc
set accountDict's end to {accName:accEmails}
end repeat
return accountDict
end tell
"""
var error: NSDictionary?
var accountNames: [String] = []
// Create script object, exit if fails
guard let scriptObject = NSAppleScript(source: appleScriptSource) else {
return nil
}
// Execute script and store results, nil on error
let scriptResult = scriptObject.executeAndReturnError(&error)
if error != nil { return nil }
// Iterate over results
for index in 0...scriptResult.numberOfItems {
if let resultEntry = scriptResult.atIndex(index) {
if let resultString = resultEntry.stringValue {
// Process result handling
// accountNames.append(resultString)
}
}
}
return accountNames
}
}
Questions
Most important one, can I deploy the App on the App Store and use NSAppleScript as shown above?
If yes can I use the script in the manner shown above or will I need to store the script in User > Library > Application Scripts location and source it from there. This is outlined in the Scripting from a Sandbox article by Craig Hockenberry, which I cannot link due to being hosted within a not-permitted domain.
If yes what entitlements I need to give to the target.
I understand that I wouldn't be able to use ScriptingBridge, which feels more robust but wouldn't permit me to deploy the app on the AppStore.
My key objective is to programatically identify mail accounts available to Mail.app, if there is a wiser / easier way of doing that I would be more than receptive.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Entitlements
AppleScript
Mail Extensions
App Sandbox
In the Swift function at the end of this post, I use Scripting Bridge to have Finder delete a path. The variable result is a SBObject returned by the delete() function. I know that result somehow contains the new path of the deleted item in the trash folder, but I don't know how to nicely extract it as a single String.
If I print(String(describing: result)), I get output like:
<SBObject @0x0123456789ab: <class 'appf'> "AppName.app" of <class 'cfol'> ".Trash" of <class 'cfol'> "user" of <class 'cfol'> "Users" of startupDisk of application "Finder" (822)>
Is there any way to obtain the String "/Users/user/.Trash/AppName.app" from result without having to perform string parsing on the above output?
The Finder* types in the code below are from https://github.com/tingraldi/SwiftScripting/blob/master/Frameworks/FinderScripting/FinderScripting/Finder.swift
func trash(path: String) throws {
guard let finder: FinderApplication = SBApplication(bundleIdentifier: "com.apple.finder") else {
throw runtimeError("Failed to obtain Finder access: com.apple.finder does not exist")
}
guard let items = finder.items else {
throw runtimeError("Failed to obtain Finder access: finder.items does not exist")
}
let object = items().object(atLocation: URL(fileURLWithPath: path))
guard let item = object as? FinderItem else {
throw runtimeError(
"""
Failed to obtain Finder access: finder.items().object(atLocation: URL(fileURLWithPath: \
\"\(path)\") is a '\(type(of: object))' that does not conform to 'FinderItem'
"""
)
}
guard let delete = item.delete else {
throw runtimeError("Failed to obtain Finder access: FinderItem.delete does not exist")
}
let result = delete()
}
Hello,
We are working on automating some processes for our mac virtual machines pool, and one of the things we are looking for is where we can download various different versions of macOS.
When going to the download section of the apple dev portal, it only gives a download link of the latest macOS. Is there no way to obtain download URLs for previous macOS versions as well? For instance, we are trying to validate our automation scripts against Sonoma macOS so we are looking for the download URL , to put in our scripts , or to manually download the file ourselves.
Thanks!
Hi all
I work in music production, the way the tools are set up is we use many tools (plugins) inside one larger app (a DAW), as such the process of setting up a machine to do work involves running 50-100+ different installers to get all tools installed. I'd like to write a small app that will automate the install process. I have a working approach for this where all steps work when run individually in terminal or via AppleScript, but as I create one unifying app I am running into an issue where any app I create in Xcode is not allowed to mount DMGs or give commands to terminal (even if I make a build app package and move it out of the Xcode directory, and even if I give explicit permission via settings) and if I try to have the app try to do the works via terminal it also can't seem to access terminal. I think there are some limitations I'm missing here. Any tips?
Topic:
App & System Services
SubTopic:
Automation & Scripting
I am unable to get a result from a simple AppleScript calculator set of commands.
The calculator shows the right result, but I cannot capture the result to place in the clipboard and read it.
I also ran this in the script editor.
Python File
(Public dupe of FB16477656)
The Shortcuts app allows you to parameterise the input for an action using variables or allowing "Ask every time". This option DOES NOT show when conforming my AppEntity.defaultQuery Struct to EntityStringQuery:
But it DOES shows when confirming to EntityQuery:
As discussed on this forum post (or FB13253161) my AppEntity.defaultQuery HAS TO confirm to EntityStringQuery to allow for searching by String from Siri Voice input.
To summarise:
With EntityQuery:
My Intent looks like it supports variables via the Shortcuts app. But will end up in an endless loop because there is no entities(matching string: String) function.
This will allow me to choose an item via the Shorcuts.app UI
With EntityStringQuery:
My Intent does not support variables via the Shortcuts app.
I am not allows to choose an item via the Shorcuts.app UI.
Even weirder, if i set up the shortcut with using a build with EntityQuery and then do another build with EntityStringQuery it works as expected.
Code:
/*
Works with Siri to find a match, doesn't show "Ask every time"
*/
public struct WidgetStationQuery: EntityStringQuery {
public init() { }
public func entities(matching string: String) async throws -> [Station] {
let stations = [Station(id: "car", name: "car"), Station(id: "bike", name: "bike")]
return stations.filter { $0.id.lowercased() == string.lowercased() }
}
public func entities(for identifiers: [Station.ID]) async throws -> [Station] {
let stations = [Station(id: "car", name: "car"), Station(id: "bike", name: "bike")]
return stations.filter { identifiers.contains($0.id.lowercased()) }
}
public func suggestedEntities() async throws -> [Station] {
return [Station(id: "car", name: "car"), Station(id: "bike", name: "bike")]
}
public func defaultResult() async -> Station? {
try? await suggestedEntities().first
}
}
/*
DOES NOT work with Siri to find a match, but Shortcuts shows "Ask every time"
*/
public struct WidgetBrokenStationQuery: EntityQuery {
public init() { }
public func entities(matching string: String) async throws -> [Station] {
let stations = [Station(id: "car", name: "car"), Station(id: "bike", name: "bike")]
return stations.filter { $0.id.lowercased() == string.lowercased() }
}
public func entities(for identifiers: [Station.ID]) async throws -> [Station] {
let stations = [Station(id: "car", name: "car"), Station(id: "bike", name: "bike")]
return stations.filter { identifiers.contains($0.id.lowercased()) }
}
public func suggestedEntities() async throws -> [Station] {
return [Station(id: "car", name: "car"), Station(id: "bike", name: "bike")]
}
public func defaultResult() async -> Station? {
try? await suggestedEntities().first
}
}```
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Siri and Voice
Shortcuts
Intents
App Intents
Instead of a .sdef file (or older formats) made in advance and stored in an app’s bundle, I wonder if the script dictionary can be set soon after the app opens? I seen related API, with a note that the scripting file reader ultimately calls that API. I grok about 90% of that API, but I’m not sure it’s possible.
I'm currently trying to use the new @UnionValue macro.
From what I understood, it allows multiple types for a parameter.
I created the following enum:
@UnionValue
enum IntentDuration {
case int(Int)
case duration(Measurement<UnitDuration>)
}
Then, I tried to use it in the following AppIntent:
struct MyIntent: AppIntent {
static let title: LocalizedStringResource = "intent.title"
static let description = IntentDescription("intent.description")
static let openAppWhenRun: Bool = true
@Parameter var duration: IntentDuration
@Dependency
private var appManager: AppManager
@MainActor
func perform() async throws -> some IntentResult {
// My action
return .result()
}
}
However, I get the following error from Xcode at the @Parameter line:
'init()' is unavailable
Did I wrongly understand how this works? Is there another way to accept multiple types for a parameter?
I didn't manage to find any docs on this.
I'm unable to fix syntax errors when using folders such as “greg’s folder"
error "86:87: syntax error: Expected “"” but found unknown token. (-2741)" number 1
i’ve created an apple script to run python tool to extract “.rpa” files. the script works well except to selecting games that are in a folder with “‘".
any ideas to properly to this?
thank you.
-- Function to escape special characters in POSIX paths for safe shell execution
on escapePOSIXPath(originalPath)
set AppleScript's text item delimiters to "'"
set pathParts to text items of originalPath
set AppleScript's text item delimiters to "'\\''"
set escapedPath to pathParts as text
set AppleScript's text item delimiters to "" -- Reset delimiters
-- Wrap in single quotes
return "'" & escapedPath & "'"
end escapePOSIXPath
-- Get the current app's POSIX path
set currentAppPath to POSIX path of (path to me)
-- Construct the expected path for rpatool.py
set scriptPath to currentAppPath & "Contents/Resources/Scripts/rpatool.py"
-- Check if rpatool.py exists
set scriptExists to do shell script "test -e " & quoted form of scriptPath & " && echo true || echo false"
if scriptExists is "false" then
-- Ask user to select the rpatool.py file
display dialog "rpatool.py was not found. Please select its location."
set rpaToolFile to choose file with prompt "Select the rpatool.py script" of type {"public.python-script"}
set scriptPath to POSIX path of rpaToolFile
end if
-- Escape the path for safe execution
set scriptPath to escapePOSIXPath(scriptPath)
-- Prompt user to select the game application
set appFile to choose file with prompt "Select the Game app with RPA files" of type {"com.apple.application"}
set appPath to POSIX path of appFile
set gameFolderPath to appPath & "/Contents/Resources/autorun/game"
-- Check if the 'game' folder exists
set gameFolderExists to do shell script "test -d " & quoted form of gameFolderPath & " && echo true || echo false"
if gameFolderExists is "false" then
display dialog "The 'game' folder was not found in the selected app's directory. Exiting..."
return
end if
-- Find all .rpa files in the game folder
set fileList to paragraphs of (do shell script "find " & quoted form of gameFolderPath & " -name '*.rpa' -type f")
-- Check if .rpa files exist
if fileList is {} then
display dialog "No .rpa files found in the 'game' folder. Exiting..."
return
end if
-- Open Terminal and change directory
set firstCommand to "cd " & quoted form of gameFolderPath
do shell script "osascript -e " & quoted form of ("tell application \"Terminal\" to do script \"" & firstCommand & "\"")
-- Process each .rpa file in Terminal
display dialog "Extraction will start in Terminal and will process " & (count of fileList) & " .rpa files."
repeat with aFile in fileList
set aFile to escapePOSIXPath(aFile)
set extractionCommand to "python3 " & scriptPath & " -x " & aFile
-- Execute in Terminal
try
do shell script "osascript -e " & quoted form of ("tell application \"Terminal\" to do script \"" & extractionCommand & "\" in front window")
delay 0.5
do shell script "osascript -e " & quoted form of "tell application \"Terminal\" to activate"
on error errMsg
display dialog "Error executing command: " & errMsg
end try
end repeat
Test Run with error:
tell current application
path to current application
--> alias "Macintosh HD:Users:Greg:Downloads:Ren'Py:RPA Extractor Mac 2.9.scpt"
do shell script "test -e '/Users/Greg/Downloads/Ren'\\''Py/RPA Extractor Mac 2.9.scptContents/Resources/Scripts/rpatool.py' && echo true || echo false"
--> "false"
end tell
tell application "Script Editor"
display dialog "rpatool.py was not found. Please select its location."
--> {button returned:"OK"}
choose file with prompt "Select the rpatool.py script" of type {"public.python-script"}
--> alias "Macintosh HD:Users:Greg:Downloads:Ren'Py:Test Game:rpatool.py"
choose file with prompt "Select the Game app with RPA files" of type {"com.apple.application"}
--> alias "Macintosh HD:Users:Greg:Downloads:Ren'Py:Test Game:Test Game.app:"
end tell
tell current application
do shell script "test -d '/Users/Greg/Downloads/Ren'\\''Py/Test Game/Test Game.app//Contents/Resources/autorun/game' && echo true || echo false"
--> "true"
do shell script "find '/Users/Greg/Downloads/Ren'\\''Py/Test Game/Test Game.app//Contents/Resources/autorun/game' -name '*.rpa' -type f"
--> "/Users/Greg/Downloads/Ren'Py/Test Game/Test Game.app//Contents/Resources/autorun/game/code.rpa
/Users/Greg/Downloads/Ren'Py/Test Game/Test Game.app//Contents/Resources/autorun/game/fonts.rpa
/Users/Greg/Downloads/Ren'Py/Test Game/Test Game.app//Contents/Resources/autorun/game/sounds.rpa"
do shell script "osascript -e 'tell application \"Terminal\" to do script \"cd '\\''/Users/Greg/Downloads/Ren'\\''\\'\\'''\\''Py/Test Game/Test Game.app//Contents/Resources/autorun/game'\\''\"'"
--> error "73:74: syntax error: Expected “\"” but found unknown token. (-2741)" number 1
Result:
error "73:74: syntax error: Expected “\"” but found unknown token. (-2741)" number 1
I've created an OpenIntent with an AppEntity as target.
Now I want to receive this entity when the intent is executed and the app is opened. How can I do that?
I can't find any information about it and there are no method for this in the AppDelegate
I have a chat/search functionality in my app, I want to integrate siri where user can say something "Hey siri! Ask myApp to get latest news" then I want to invoke my search functionality with "get latest news". I see iOS apps like chatGPT and youtube have already achieved this.
I am able to invoke the intent with static phrase which is expecting the parameter, user is able to provide the value when prompted after requestValueDialog. But it is a 2 step process for end user. I want to achieve in a single step.
struct CombinedSiriShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
return [
AppShortcut(
intent: ShowSpecificNewsArticleIntent(),
phrases: [
"Ask \(.applicationName) to run a query:",
],
shortTitle: "Specific News Article",
systemImageName: "doc.text.fill"
),
AppShortcut(
intent: TestQuery(),
phrases: [
"Ask \(.applicationName) to \(\.$query)",
],
shortTitle: "Test intent",
systemImageName: "doc.text.fill"
),
]
}
}
struct ShowSpecificNewsArticleIntent: AppIntent {
static var title: LocalizedStringResource = "Show Specific News Article"
static var description = IntentDescription(
"Provides details about a specific news article based on its title."
)
@Parameter(title: "Query")
var query: String
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView {
print("in show specific intent");
print(query);
return .result(dialog: "view more about: \(query)")
}
}
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags:
Siri and Voice
SiriKit
App Intents
I dont know if this is the appropriate forum for this.
Answers I've found on the web points me towards intentions, but somehow I couldnt make it work.
Im trying to activate siri on carplay to ask user for voice input then make a search.
Is this a custom intent capability or is there any other way.
Hello,
I have two related questions:
in this AppIntent:
https://github.com/poml88/FLwatch/blob/moresimple/SharedPhoneWatch/AppIntents/AddInsulin.swift#L2
i am trying to work with are returned Double as the parameter.
But it does not fully work, because
there is a locale issue. in some languages the decimal point is a comme. If that is so, Siri returns 3,5 but the system does not use it as a double. How to solve that?
or, she is returning five, not 5 and again. The system does not recognise the double.
It seems Apple has some resolvers for this, for example: DoubleFromStringResolver.
https://developer.apple.com/documentation/appintents/resolvers
But I cannot figure out how to use them are how to call that resolver.
Can somebody help, please?
Thanks.
After updating to macOS 14.4.1 keynote can't find all the outside video links.
I have over 15 keynote presentations that I use to show videos.
I have over 1500 videos.
If I manually replace each video, I lose all the settings (thumbnails, cropping, animations, etc.).
That's 15 years of work lost!
Apple engineers tell me there's no other solution but to replace the videos manually.
I've tried creating scripts via AIs but none of them work.
Does anyone have any ideas?
Topic:
App & System Services
SubTopic:
Automation & Scripting