Automation & Scripting

RSS for tag

Learn about scripting languages and automation frameworks available on the platform to automate repetitive tasks.

Automation & Scripting Documentation

Posts under Automation & Scripting subtopic

Post

Replies

Boosts

Views

Activity

Apple Script for Music app no longer supports current track event
AppleScript for the Music app no longer supports the current track event. Before macOS Tahoe, running the following script in Script Editor would return the current track information: tell application "Music" return name of current track end tell However, when I run this script on a device with macOS 26 Tahoe, I receive this error: "Result: error "Music got an error: Can’t get name of current track." number -1728 from name of current track” I've tested this extensively, and here are my findings: Going to the “songs” tab and playing something from there makes everything work. Playing any song directly will make it work with current track UNLESS this song is NOT in your Music library (either added through Apple Music or uploaded). If you play a song not in your library, current track is not updated even if you clicked on it specifically. Playing an album (in your library obviously) makes all the tracks within it appear in current track until autoplay takes over. Any autoplayed track won’t appear in current track even if in your library (unless: see the last bulletpoint) Music played through the “songs” tab all appear in current track even if autoplay kicks in. I assume this is because this tab is an iTunes legacy (visually and under the hood) and doesn’t use the modern autoplay. This tab also won’t play non-library songs unlike the “albums” tab which seems to use the correct autoplay and suffers the same symptoms as the “recently added”, “home”, “radio”, etc… tabs. Is this a bug, or has Apple simply deprecated this functionality?
3
0
92
5d
Debugging updateAppShortcutParameters not adding shortcuts to Shortcuts App
So I'm developing an ios application which should be showing shortcuts, but its not. I'm not sure how to debug why the functionality isnt working. Believe I'm correctly calling AppShortcutsProvider's updateAppShortcutParameters, but I dont see any errors in the console showing me a problem. And in fact, I made a simplified just swift version that works before I tried to integrate it into a more complex project. But now I'm at a loss as to what is going wrong or what debug tools I can use to figure it out. Any help would be appreciated. When building my project I see: 025-08-18 14:07:49.371 appintentsmetadataprocessor[57506:35387547] Starting appintentsmetadataprocessor export 2025-08-18 14:07:49.414 appintentsmetadataprocessor[57506:35387547] Writing Metadata.appintents 2025-08-18 14:07:49.414 appintentsmetadataprocessor[57506:35387547] Metadata root: /Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/Metadata.appintents AppIntentsSSUTraining (in target 'UnityFramework' from project 'Unity-iPhone') cd /Users/jpetersen/no_doc_repos/payments_ios_investigation/SpotlightSearch/client/Build /Applications/Xcode_16.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/appintentsnltrainingprocessor --infoplist-path /Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/Info.plist --temp-dir-path /Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/ssu --bundle-id com.unity3d.framework --product-path /Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework --extracted-metadata-path /Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/Metadata.appintents --archive-ssu-assets 2025-08-18 14:07:49.436 appintentsnltrainingprocessor[57507:35387550] Parsing options for appintentsnltrainingprocessor 2025-08-18 14:07:49.437 appintentsnltrainingprocessor[57507:35387550] Starting AppIntents SSU YAML Generation 2025-08-18 14:07:49.444 appintentsnltrainingprocessor[57507:35387550] Training 'Start ${+applicationName}' for English 2025-08-18 14:07:49.444 appintentsnltrainingprocessor[57507:35387550] Training 'Play ${ShortcutEntity}|Play ${ShortcutEntity} on ${+applicationName}' for English 2025-08-18 14:07:49.444 appintentsnltrainingprocessor[57507:35387550] Training Negative Phrases '' for English 2025-08-18 14:07:49.444 appintentsnltrainingprocessor[57507:35387550] Application name 'UnityFramework' for English 2025-08-18 14:07:49.449 appintentsnltrainingprocessor[57507:35387550] Generated AppIntents SSU YAML files in file:///Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/UnityFramework.build/ssu/ 2025-08-18 14:07:49.449 appintentsnltrainingprocessor[57507:35387550] Copied AppIntents SSU YAML files to file:///Users/jpetersen/Library/Developer/Xcode/DerivedData/Unity-iPhone-dtnhxevagfkzsjdavesziaqrwisr/Build/Products/ReleaseForRunning-iphoneos/UnityFramework.framework/Metadata.appintents/ So I think it should be making the required app intent data :shrug:
2
0
62
1w
Transaction Shortcuts + AppIntent is flaky occasionally
Hello, I made myself an app to track my expenses. The most important event is when I make a purchase via apple wallet. What happens is sometimes the values from Merchant and Amount are; Merchant = " " Amount = 0.0 Has anyone experienced this, is there something I can do about it ? I was thinking that sometimes maybe speed connection and service is something that might make an impact Does anyone here know something about the topic ?
3
0
127
2w
How to configure com.apple.security.scripting-targets in .entitlements file?
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?
1
0
117
3w
Siri complains AppIntent is not registered
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" ) } }
1
0
48
3w
how to use a 3D short cut with the totally closed application
I'm soliciting you because I'm having a problem using the 3D short cut for my ios application in uikit in the AppDelegate file but it's impossible to redirect the route when the user has completely killed the application. It works as a background application. I'd like it to redirect to the searchPage search page when the application is fully closed and the user clicks on search with 3D touch. final class AppDelegate: UIResponder, UIApplicationDelegate { lazy var window: UIWindow? = { return UIWindow(frame: UIScreen.main.bounds) }() private let appDependencyContainer = Container() private let disposeBag = DisposeBag() var pendingDeeplink: String? private lazy var onboardingNavigationController: UINavigationController = { let navigationController = UINavigationController(nibName: nil, bundle: nil) navigationController.setNavigationBarHidden(true, animated: false) return navigationController }() private func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) { guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let window = windowScene.windows.first(where: { $0.isKeyWindow }), let rootVC = window.rootViewController else { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in self?.handleShortcutItem(shortcutItem) } return } if let presentedVC = rootVC.presentedViewController { presentedVC.dismiss(animated: !UIAccessibility.isReduceMotionEnabled) { [weak self] in self?.executeShortcutNavigation(shortcutItem) } } else { executeShortcutNavigation(shortcutItem) } } private func executeShortcutNavigation(_ shortcutItem: UIApplicationShortcutItem) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in guard let self = self else { return } switch shortcutItem.type { case ShortcutType.searchAction.rawValue: self.mainRouter.drive(to: .searchPage(.show), origin: AppRoutingOrigin()) case ShortcutType.playAction.rawValue: self.mainRouter.drive(to: .live(channel: Channel(), appTabOrigin: AppTabOrigin.navigation.rawValue), origin: AppRoutingOrigin()) case ShortcutType.myListHistoryAction.rawValue: self.mainRouter.drive(to: .myList(.history), origin: AppRoutingOrigin()) default: break } } } What I've tried: Adding delays with DispatchQueue.main.asyncAfter Checking for window availability and rootViewController Dismissing presented view controllers before navigation Environment: iOS 15+ Swift 6 Using custom router system (mainRouter) App supports both SwiftUI and UIKit Questions: What's the best practice for handling shortcuts on cold launch vs warm launch? How can I ensure the router is properly initialized before navigation?
0
0
64
Jul ’25
macOS 26: Automator 3rd party actions cannot be configured
After installing my notarized 3rd party app in a Tahoe VM, its embedded Automator actions can not be configured in Automator while defining a workflow: After adding the actions (enabling 3rd party extensions), their views / UI elements do not respond to any mouse event. When enabling „show this action when running“, the options can be changed during execution of the workflow. Needless to say: Adjusting these action settings in Automator was working for years, macOS 12 - 15 and before. Reported via Feedback Assistent (FB19015185). Can anybody confirm this issue with Automator actions?
1
0
65
Jul ’25
Siri not prompting to enable for AppIntent
We're trying to add an AppIntent to our very complex and large app that works with Siri. What we've found through numerous different configuration attempts is that when the Siri toggle is turned off on in the Shortcuts app for our app, when we speak our phrase to Siri we get this prompt: " hasn't added support for that with Siri." with an "Open " button. When we speak the phrase while the app is open, we get the prompt that says "Turn on "" shortcuts with Siri?" with a "Turn On" button. When the Siri toggle is turned on for our app in the Shortcuts app, all of our phrases work as expected. Is there some kind of configuration we're missing? There doesn't seem to be a lot of documentation. We've tried to match an example app's approach (AcceleratingAppInteractionsWithAppIntents) to no avail. Our app intents live in an xcframework if that makes a difference, but we've also tried moving it out of xcframework without success. This is a blocker to us shipping this feature. Thanks!
2
0
127
Jul ’25
Shortcuts: Expense Tracker Header Lines
Issue: CSV Headings Not Appearing in Shortcut-Generated File I'm using an iPhone 16 Pro with iOS 18.5 and the latest Shortcuts app to log expenses into a CSV file. The shortcut works fine, except the resulting file doesn't include the column headings. Here’s what I’ve done: Created a file called Expenses.csv with this single header line: Date,Price,Category,Store,Notes,Location Saved it to both /iCloud Drive and /iCloud Drive/Shortcuts (via iCloud on my Windows PC). My Shortcut builds the CSV line from inputs (date, price, category, etc.) and appends it to the file. I renamed the variables only in the final “Text” block, since renaming in earlier blocks seems no longer possible in this Shortcuts version. Despite this setup, the file doesn’t preserve the header row—it either doesn’t show up, or gets overwritten. Goal: Have a persistent CSV file with the correct headers once, and each new entry appended below the correct columns. Can anyone help me figure out what I’m doing wrong?
0
0
226
Jul ’25
Terminal Command or AppleScript to Set Audio Balance to Perfect Center?
Hi everyone, I'm looking for a way to programmatically set the left/right audio balance to perfect center (50/50) using either a Terminal command or AppleScript. Background: The audio balance slider in System Settings > Sound > Output & Input works functionally, but I have difficulty determining when it's positioned at the exact center point. The visual nature of the slider makes it challenging for me to achieve the precision I need, and I end up adjusting it repeatedly trying to get it perfectly centered. What I'm looking for: A Terminal command that can set the audio balance to exact center An AppleScript that accomplishes the same thing Any other programmatic method to ensure perfect 50/50 balance I've tried searching through the defaults command documentation and Core Audio frameworks but haven't found the right approach yet. Has anyone successfully automated this setting before? Any help would be greatly appreciated! Thanks in advance, Dylan
0
0
57
Jul ’25
Array of AppEnum in a Parameter will always be empty
Consider the following in an AppIntent: struct TestIntent: AppIntent { static let title: LocalizedStringResource = "Test Intent" static var parameterSummary: some ParameterSummary { Summary("Test") { \.$options } } enum Option: Int, CaseIterable, AppEnum { case one case two case three case four case five case six static let typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation( name: "Options" ) static let caseDisplayRepresentations: [Option: DisplayRepresentation] = [ .one: DisplayRepresentation(title: "One"), .two: DisplayRepresentation(title: "Two"), .three: DisplayRepresentation(title: "Three"), .four: DisplayRepresentation(title: "Four"), .five: DisplayRepresentation(title: "Five"), .six: DisplayRepresentation(title: "Six"), ] } @Parameter(title: "Options", default: []) var options: [Option] @MainActor func perform() async throws -> some IntentResult { print(options) return .result() } } In Shortcuts, this will turn into a dropdown where you can check multiple Option values. However, when perform() is called, options will be an empty array regardless of what the user selects. This is observed on both iOS 18.5 and macOS 15.5. However, on iOS 26.0 beta and macOS 26.0 beta, the issue seems to be resolved and options contains all the checked options. However, we do back deploy to current/previous iOS/macOS versions. How can we provide a multiple choice selection of fixed values on these older versions?
3
0
127
Jul ’25
I want the "Folder" property of a folder not it's class.
I'm trying to set a boolean value to myVariable using the "Folder" property, but the Applescript editor keeps interpreting it as a class. Here is a shorted code. this is part of a bigger code to identify files dropped into a folder and create a new folder which it renames based on the date of the file that is dropped into the folder. Unfortunately, it keeps making folders every time it makes a new folder. Resalting in continuous loop of folders being created and renamed to "2025". The plan is to us an IF condition to prevent the creation of folders when a folder/s are dropped into my folder with my Folder Action. property directory : "Catalina:Users:Username:Desktop:Folder:File.pdf tell application "Finder" set pathname to POSIX path of directory set item_info to the info for directory set myVariable to Folder of item_info return myVariable end tell I noticed the following when I compile the script The color of the "Folder" is blue. I believe this means it's a class. Normally when I call a property, the color turns pink. it does it correctly when I use "set the file_name to the "name" of this_file". I also tried declaring the "Folder" property in brackets "Folder". did not help I noticed the following when I run the script: It returns ---error number -10004 "A privilege violation occurred. When it runs the "info for" command. I gave the Script Editor Full File access, Full Accessibility access and the FolderActionsDispatcher has full Finder access. Can anyone point me in the right direction! What is the cause of the privilege violation or how would I find what the cause is? How do I force the Script Editor to get the "Folder" property of a folder?
1
0
134
Jul ’25
AudioPlaybackIntent usage requesting a screen unlock
Hello, I have an AppIntent that uses the AudioPlaybackIntent to trigger my app to open and initiate an AVPlayer that plays back a media stream I control. When the phone is unlocked, everything works as I expect. The app opens and plays the audio. However, when the phone is locked, any attempt to invoke the intent causes a "Request Code" dialog to be displayed. This seems counter to what I would expect with the AudioPlaybackIntent usage. Am I able to accomplish what I'm after here with AppIntents? Does the fact that I'm using openAppWhenRun require me to have the phone unlocked somehow? import AppIntents import Foundation struct PlayStationAppIntent: AudioPlaybackIntent { static var title: LocalizedStringResource = "Play radio station" static var description: IntentDescription = .init("Play radio station") static var notification: Notification.Name = .init("playStation") static var openAppWhenRun: Bool = true init() {} func perform() async throws -> some IntentResult { AudioPlayerService.shared.play() return .result() } }
0
0
87
Jul ’25
Unable to find AppShortcutProvider
Hello, I'm evaluating if it's worth to expose shortcuts from our app, it seems to be working fine on my machine - Apple Silicon, latest Tahoe beta, Xcode 26 beta. But if I compile the same code on our intel build agents which are running latest macOS 15 and Xcode 26 beta, once I install the bundle to /Applications on Tahoe I don't see any shortcuts. Only other difference is that CI build is signed with distribution DeveloperID certificate - I re-signed the build with my dev certificate and it has no effect. I found out that linkd is somehow involved in the discovery process and most relevant logs look like this: default (...) linkd Registry com.**** is not link enabled com.apple.appintents debug (...) linkd ApplicationService Created AppShortcutClient with bundleId: com.**** com.apple.appintents error (...) linkd AppService Unable to find AppShortcutProvider for com.**** com.apple.appintents Could you please advice where to look for the problem?
0
0
101
Jul ’25
Trouble implementing search via Siri
Hi, we're having trouble implementing search through Siri voice commands. We already did it successfully for audio playback using INPlayMediaIntentHandling. For search, none of the available ways works. Both INSearchForMediaIntentHandling and ShowInAppSearchResultsIntent never open the App in the first place. We tried various commands, but e.g. "Search for " sometimes opens the Apple Music app and sometimes shows a Google search widget. Our app is never taken into consideration for providing any results. We implemented all steps mentioned in WWDC videos and documentation (e.g. https://developer.apple.com/documentation/appintents/making-in-app-search-actions-available-to-siri-and-apple-intelligence), but nothing seems to work. We're mainly testing on iOS 18 currently. Any idea why this is not working?
0
0
43
Jul ’25
Issue syntax “AND” conditions to trigger automation
I’m looking into activating my gate (has a dedicated app to it) while getting near home. i thought that a combination of Car bluetooth connection/Carplay connection as well as a 50 meter radius from home location would be nice to trigger the gate app. However, I find it hard to set these 2 parallel conditions in Shortcuts. I managed to set connection to car’s Bluetooth, but next screen would suggest the “do” action rather than offer additional conditions. i couldn‘t handle the “if” option. would like some help.
0
0
95
Jul ’25
Siri Intent: 'Siri, count for '
Hi, I’m developing an app, which just like Clock App, uses multiple counters. I want to speak Siri commands, such as “Siri, count for one hour”. ‘count’ is the alternative app name. My AppIntent has a parameter, and Siri understands if I say “Siri, count” and asks for duration in a separate step. It runs fine, but I can’t figure out how to run the command with the duration specified upfront, without any subsequent questions from Siri. Clock App has this functionality, so it can be done. //title //perform() @Parameter(title: "Duration") var minutes: Measurement<UnitDuration> } I have a struct ShortcutsProvider: AppShortcutsProvider, phrases accept only parameters of type AppEnum or AppEntity.
1
0
77
Jul ’25