Automation & Scripting

RSS for tag

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

Automation & Scripting Documentation

Post

Replies

Boosts

Views

Activity

Feature Request: Enhanced Automation for Blocking Contacts and Uninstalling Apps
Hello everyone, I would like to propose a feature enhancement for iOS that could greatly benefit many users. Specifically, I am suggesting the introduction of automation capabilities within the Shortcuts app that would allow users to: Block Contacts on Messaging Apps: Enable Shortcuts to interact with apps like WhatsApp to block specific contacts based on predefined conditions or user actions. Uninstall Apps: Allow Shortcuts to uninstall specified apps automatically, which could be very useful for managing app clutter and storage. Benefits: Improved User Experience: These features would streamline tasks that currently require manual intervention, saving time and effort. Enhanced Control: Users would have more control over their device's functionality, allowing for better customization and management. Implementation Considerations: Privacy and Security: Implementing these features with appropriate security measures to ensure user privacy is not compromised. User Permissions: Ensure that users explicitly grant permissions for these automations to run, maintaining transparency and control. Use Cases: Parental Controls: Parents can automate the blocking of certain contacts on their children's devices. App Management: Users can create automations to periodically clean up unused apps, improving device performance. Community Input: I would love to hear your thoughts on this suggestion. How do you think these features could be implemented effectively? Are there any potential challenges you foresee? Thank you for considering this request. Let's work together to make iOS even more powerful and user-friendly! Best regards, Sagayaraj Danial
0
0
74
1d
Trouble with AppleScript Permissions and ShazamKit Integration in macOS App
Hello fellow developers, I am developing a macOS app called "Playlist Plunderer 2," aimed at using AppleScript to control the Music app to play songs and employing ShazamKit to recognize these songs and update their metadata. Despite setting up the entitlements and plist files correctly, I'm encountering issues with gaining the necessary AppleScript permissions, and my app is not appearing under 'Automation' in System Preferences. Additionally, ShazamKit fails to match songs, consistently returning error 201. Here are the specifics of my setup and what I've tried so far: Xcode Version: 15.4, macOS 14.1.2 Entitlements Configured: Includes permissions for Apple events, audio input, and scripting targets for the Music app. Capabilities: ShazamKit and ScriptingBridge frameworks integrated, set to "Do Not Embed." Info.plist Adjustments: Added "Privacy - Microphone Usage Description." Scripting: Manual AppleScript commands outside of Xcode succeed, but the app's scripts do not trigger. Entitlements File: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.automation.apple-events</key> <true/> <key>com.apple.security.device.audio-input</key> <true/> <key>com.apple.security.files.user-selected.read-only</key> <true/> <key>com.apple.security.scripting-targets</key> <dict> <key>com.apple.Music</key> <array> <string>com.apple.Music.playback</string> <string>com.apple.Music.library.read-write</string> </array> </dict> </dict> </plist> I am having issues controlling the music app (itunes) from the apple script within my xcode project. the objective of the app is to rewrite the metadata of songs inside a folder in my Music app, this folder is titled Playlist Plunderer. The way I intend for the app to function is, the app will play the songs in the playlist, and then it will use shazamkit to recognize the song thats playing, it will then copy the metadata results of that song to rewrite the metadata of the song in the music playlist. I am still in the beginning stages. and I am very new to xcode. I created a apple developer account, paid the $99 and it is active, and I added the identifier bundle to the account from my app. I am VERY new to xcode,(this is my first project) my development team is set ( Shane Vincent), and the app is set to automatically manage signing, under app sandbox. i have audio input checked, under hardened runtime/ resource access audio input is checked. in build settings the path to the info.plist file is correct, the info.plist contains Privacy - Microphone Usage Description that I added i think it was called NSMmicriphone or something, with a description that reads "This app needs to access the microphone to identify songs using ShazamKit." the app appears under System Preferences > Security & Privacy > Privacy > Microphone but not under System Preferences > Security & Privacy > Privacy > Automation it is being made on macOS 14.1.2 (23B92) and xcode Version 15.4 (15F31d) Under framework library, and embedded content, I have added two frameworks, Shazamkit.framework, and ScriptingBridge.framework, both set to do not embed Current Issue: AppleScript fails to authorize with the Music app, and ShazamKit errors suggest an issue with song matching. Has anyone faced similar challenges or can offer guidance on how to ensure AppleScript and ShazamKit function correctly within a sandboxed macOS app? Any insights into troubleshooting or configuring entitlements more effectively would be greatly appreciated. Thanks for your help!
0
0
54
2d
Version 15.4 (15F31d) Xcode NSAppleScript of Safari broken
All attempts to script Safari in Xcode using NSAppleScript returns the following message. error: { NSAppleScriptErrorAppName = Safari; NSAppleScriptErrorBriefMessage = "Application isn\U2019t running."; NSAppleScriptErrorMessage = "Safari got an error: Application isn\U2019t running."; NSAppleScriptErrorNumber = "-600"; NSAppleScriptErrorRange = "NSRange: {32, 3}"; } Latest script attempt: func getHTML() -&gt; String { let source = """ tell application "Safari" get URL of tab 1 of window 1 end tell """ //print(source) var a = "hello" var error: NSDictionary? if let scriptObject = NSAppleScript(source: source) { if let scriptResult = scriptObject.executeAndReturnError(&amp;error).stringValue { a = scriptResult print(scriptResult) } else if (error != nil) { print("error: ",error!) } } return a }
3
0
187
1w
iOS Shortcuts Error Codes/Status
I’ve two automations set. Send a notification when battery rises above 80% Set Always ON display off on apple watch (via Shortcuts Automation, everyday at 12 a) For these aforementioned shortcuts I get the following errors frequently, on my Lock Screen, Wha is INCExtensionErrorDomain error 1307 and Remote execution timed out error? And how can these errors be mitigated?
0
0
142
1w
Can't write a property through ScriptingBridge
Staring to use ScriptingBridge in Swift to enable faster scripting access to an external app (Devonthink) and therefore avoid having to use an AppleScript as a conduit to call a Swift command line utility and deal with its results. The plan is to be able to read the plaintext of a record (no problem) and change the record name in Devonthink based on its contents. But I can’t seem to write to a property, instead getting an error “Cannot assign to property: ‘***’ is immutable”. Any guidance how to get around this?
1
0
177
3w
Full uninstall of an app
Hello all, I am wondering if anyone can help me with writing a script that fully uninstalls an app with one click or can point me to a script already written please? So that when I click the script it uninstalls the app and leaves nothing behind. So when I click finder and use the search function with the name of the app, then click add and then name matches (input name of app) then click add and select system files are included, nothing comes up as the script has completely removed it from my system. I am Using Mac Mini M2 Pro 16gb ram and macOS Sonoma. Thank you
0
0
197
Jun ’24
Script to automount 1 local networkshare an 1 external networkshare
Hi, I have one Synology NAS at home and one Synology NAS on an external place. On my MacBook I want to create a script that first mount the local NAS, wait 30 seconds (to let OpenVPN startup and connecting to my DDNS) and mount the external NAS. When mounting both NASses, I will let the script checking if both shares still mounted and if not, try to remount. I've created the code below but it looks like the script only runs te first lines and only mount the local NAS. global startup set startup to true on idle if startup then mount_share("smb", "Lisa", "NAS_name", "Data/Mijn Afbeeldingen") set startup to false return 30 else mount_share("smb", "Lisa", "NAS_name", "Data/Mijn Afbeeldingen") mount_share("smb", "Lisa", "IP-external NAS", "Backup Lisa") return 120 end if end idle on mount_share(protocol, account, server, share) set x to 0 -- try a few time in case the server has to wake up first. -- don't do anything if the share is already mounted repeat until x > 4 or (list disks) contains share tell application "Finder" try mount volume protocol & "://" & account & "@" & server & "/" & share on error set x to x + 1 delay 30 end try end tell end repeat end mount_share Hopefully someone can help me
0
0
146
Jun ’24
"Vou" to "vouch" issue. Automatic text filling causing major issues for portuguese users.
Since apple has added the "no opt out" automatic completion of some words in the iphone keyboard, pr at least in the latest version of IOS 17.5.1 many users that try to use the portuguese word "vou" that means "going" ar suffering from constant replacing of the word to "vouch" even with the keyboard and phone language set to portuguese and autofill turned off.
1
0
291
Jun ’24
CoreDevice framework is unable to route iOS app's stdout
I am trying to automate the installation, launch, and monitoring of iOS apps. Historically we have used ios-deploy, but as of XCode 15 and iOS 17+, using ios-deploy no longer works. See issue The CoreDevice framework and xcrun's devicectl command has many of the features I require, but in contrast to ios-deploy, executing xcrun devicectl process launch --device &lt;uuid&gt; &lt;bundle&gt; does not route the launched app's stdout the the devicectl process. From the help menu, it looks like adding the --console flag will do exactly what I want, which routes the app stdout to the devicectl process and waits for the app to exit. However, if I try running xcrun devicectl process launch --console --device &lt;uuid&gt; &lt;bundle&gt; I receive the following error ERROR: The specified operation is not implemented on this device. (com.apple.dt.CoreDeviceError error 1 (0x01)) -------------------------------------------------------------------------------- ERROR: The operation couldn't be completed. (CoreDevice.ActionError error 2.) NSDebugDescription = This operation cannot be performed on this device. It's rather unclear on what the actual issue is, and I can't find any CoreDevice documentation online to help me deduce what these error codes refer to. Any help would be appreciated!
1
1
404
Jun ’24
App Intents vs. Lock Screen
I've been working on a project with App Intents and have hit a complete wall. The desire is to have an app that allows a person to place an order of something and have that order processed while in lock screen without any intervention. Is that workflow possible without having to unlock the screen? Under what circumstances can a task be handled without unlocking the device. Going over some of the documentation about older custom intents strongly implies that this was possible under certain circumstances.
1
0
342
May ’24
iOS Automation could not run because an internal error occurred
I am developing a shortcut for an application that is currently in production. The shortcut essentially involves opening the application and launching a notification so that the AppDelegate initiates a process to scan NFC tags. To achieve this, I have an AppIntent that overrides the variable openAppWhenRun = true and an AppShortcutsProvider to implement this intent. The problem arises when a user updates to the latest version of the application and tries to implement this shortcut through an automation. The following error appears: "When 'Reader' is detected" encountered an error: The action 'Scan DMA tags' could not run because an internal error occurred. This does not always happen, only on some devices. However, if we uninstall and reinstall the application, it works perfectly. But this is not a viable solution since the application uses a database and data loss from frequent uninstallations is not acceptable. Any solution? I have tried to replicate the error but have been unable to do so. This issue has occurred on both iOS 16 and iOS 17.
0
1
303
May ’24
OSASCRIPT App suddenly executes as X86
My applescript calls a perl script to convert a file. When I call the perl from commandline, everything works fine. When I call the applescript (by dropping a file on it), this error occurs: Can't load '/Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle' for module Encode: dlopen(/Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle, 0x0001): tried: '/Library/Perl/5.30/darwin-thread-multi-2level/auto/Encode/Encode.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/ which I interprete that OSA runs in Rosetta mode now. This error did not occur at least until Mar 27, when I used it last. Of course on the same machine. How is it possible that OSA now is called under Rosetta? Has there been a chacnge in Ventura 13.6.6? How to control that this OSA runs as native arm64?
0
0
283
May ’24
Support for Automator app in macOS
Can someone update about the current state of the Automator app in macOS. Automator seems like a valuable tool for automating tasks on macOS but in the recent years I have noticed a growing emphasis on the Shortcuts app for automation. It would be great if you could clarify the following: • Current Status of Automator: Is there any official statement regarding the continued support of the Automator app in future macOS versions? • Future of Automator: Does Apple plan to introduce new features or updates for Automator in upcoming releases? • Indifference to Shortcuts App: From what I understand both the ‘Automator’ and the ‘Shortcuts’ app are used for creating workflows/shortcuts to automate tasks. What is it that Automator app has to offer which cannot be done using the Shortcuts app? assuming the continued support for the Automator app. Can all the automator workflows not be automated using the shortcuts app? I understand that Apple is constantly innovating and introducing new tools. However, clarity regarding the future of Automator would be helpful for users like myself. In addition, as a developer I wanted to offer some actions for my application in the Automator app, so that the user can make use of it to create some workflows. But from what I found in the apple documentation here, these action are created using the ‘Automator action’ Project type template in the xcode. However, in the current version of xcode 15, this project type seems to be missing. Does it indicate that apple no longer provides support for applications to create new automator action? If not, how can I provide automator actions for my xcode application?
1
0
397
May ’24
Where can I read the help for all Do Shell Script commands?
Where can I read the help for all Do Shell Script commands? For example, there is a "test" command. Which reference book mentions this command? I.e. I want to go to some website, all the Do Shell Script commands will be there, and among these commands I will find the "test" command. Or are there no such directories and the programmer should randomly find commands on the Internet on random sites?
5
0
465
May ’24
AppleScript, Do Shell. How do I write the "test" command to the "script editor"?
Hello. How to write this command correctly on a Macbook, in the script editor, so that I can click the "Run script" button and the script will give the result: if there is no folder, then report that there is no folder, if there is a folder, then report that the folder exists. do shell script "test -d 'Users/user/Desktop/New folder'" Now, if the folder exists, an empty string ("") is returned, if the folder does not exist, the script editor reports that an error has occurred. In general, my task is to write a script that checks the existence of a folder.
12
0
674
May ’24