Scripting

RSS for tag

Scripting allows you to automate complex, repetitive, and time-consuming tasks by writing scripts that interact with apps, processes, and the operating system.

Posts under Scripting tag

29 Posts
Sort by:
Post not yet marked as solved
5 Replies
8.2k Views
Hi, Want to get your opinion on using XCUITest via XCode 7 or would you continue to use the Automation instrument in Instruments. With Instruments, I could run both Automation scripts as well as other Instruments such as allocation, leaks etc. Please share your thoughts on your choice.
Posted
by
Post marked as Apple Recommended
2.6k Views
I have started to experiment with Xcode UI testing and with in my first few tests, I am observing that the app state is being retained between tests.How I kill the app completely?http://masilotti.com/xctest-documentation/Classes/XCUIApplication.html#//api/name/terminatecommand only seems to put the app in background/suspend it
Posted
by
Post not yet marked as solved
2 Replies
1.8k Views
I have an applescript that works perfectly on my local machine. It opens the file and writes to it and then closes. My Applescript is being tested and saved as a .app so it is an application. When I put the application on my server to test out the user experience it never propely opens the file and gives me this error:"File not open with write permission.Finder got an error: File not open with write permission. (-61)"Why would this work on my local machine and not work after being downloaded from my server? I have tested that my path's are correct and like I mentioned everything works perfectly on my local MAC machine. Here is the section of my Applescript code that seems to be throwing the error:set motionFullPath to ("" & pathEffects & "" & effectPlugin & ":" & theFolders & ":" & motionFiles & "") as string set myFile to open for access file motionFullPath with write permission set endOfFile to (get eof myFile) as number if result > 0 then set theText to read myFile set eof myFile to endOfFile write "<!--uuid:" & theURL & "-->" & return & theText to myFile end if close access myFile
Posted
by
Post not yet marked as solved
15 Replies
34k Views
Trying to do a CLI build with XCode (using NativeScript).Was working fine a couple days ago. However, now I cannot get past this error when trying to build:DTDeviceKit: deviceType from 7c64d8a014fd573ca3623ef80b158e57e7aea7c5 was NULL2018-05-07 11:57:54.696 xcodebuild[14808:865317] DVTPortal: Service '<DVTPortalViewDeveloperService: 0x7fe4e17686d0; action='viewDeveloper'>' encountered an unexpected result code from the portal ('1100')2018-05-07 11:57:54.696 xcodebuild[14808:865317] DVTPortal: Error:Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload=<CFBasicHash 0x7fe4e242ed70 [0x7fff9115faf0]>Whenever I open XCode and to go preferences->account, my team account already reports "Session has expired". I log in successfully, then close Xcode, then login again, and once again it says the "Session has expired".Enabled two factor authentication hasn't helped. I get the identical error from two separate machines (Mac Mini and MacBook Air). Using latest High Sierra OS and XCode.My developer accounts logs in fine to the developer portal on Apple's Developer site, iTunes connect, etc..
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
I'm writing a Cocoa app that scripts various functions of the Music app. I'm successfully scripting a number of operations (create playlist, play tracks), but all AirPlay ops (get devices, set device volume) are failing with a permissions error: "-[Music airplayDevices_]: Music got an error: A privilege violation occurred. (error -10004)"Details:I'm using the AppleScriptObjC framework from Swifttargeting Catalina/Music, but have the same failures in Mojave/iTunescode succeeds when not sandboxed - only fails in the sandboxThe entitlements file includes the following: <key>com.apple.security.scripting-targets</key> <dict> <key>com.apple.Music</key> <array> <string>com.apple.Music.device</string> <string>com.apple.Music.user-interface</string> <string>com.apple.Music.playback</string> <string>com.apple.Music.playerInfo</string> <string>com.apple.Music.library.read</string> <string>com.apple.Music.library.read-write</string> <string>com.apple.Music.podcast</string> </array> </dict>i.e. all access-groups I could find using "sdef /System/Applications/Music.app". According to the sdef, AirPlay access is controlled by com.apple.Music.playback, which is included above.I assume I need some other entitlement as well, but I can't for the life of me find out what it is.
Posted
by
Post not yet marked as solved
4 Replies
1.1k Views
When running the following AppleScript (other portions were removed for clarity)… set newDate to "1/1/1953 00:00 AM" do shell script "SetFile -d " & quoted form of newDate & " " & quoted form of filePath I can change  the created date to any year from 1970 to 2079 but attempting any year outside that range returns unpredictable results.  For instance, using 1/1/1953, the created date became February 6, 2096. But if I enter 1/1/2096 the created date becomes September 3, 2061. Any year between 1970 and 2079 yields the correct result. So, what’s the workaround? I need to be able set the year to any date from 1920 to the present and SetFile apparently can’t handle that range. 
Posted
by
Post not yet marked as solved
2 Replies
2.3k Views
Hello, i am currently trying to implement a pre build script execution in a package. I am using this tutorial to implement it. But it only shows how to use the pre build feature with an already existing feature. I want to execute a skript on my pc every time i build the project. I can't use apples prebuild skript feature in the build settings because it is a package. Right now my code looks like this: import Foundation import OSLog import PackagePlugin @main struct GenerateLocalizer: BuildToolPlugin {     do {       let commandlineOutput = try shell("./testScript.sh")     } catch {     }     return [.prebuildCommand(displayName: "Generate Strings", executable: PackagePlugin.Path("./scrips/generate_strings.sh"), arguments: [], outputFilesDirectory: target.directory)]   }   func shell(_ command: String) throws -> String {     let task = Process()     let pipe = Pipe()     task.standardOutput = pipe     task.standardError = pipe     task.arguments = [command]     os_log("%{public}@", log: log, task.arguments?.joined(separator: " ") ?? "not found")     task.launchPath = "/bin/zsh"     task.standardInput = nil     try task.run()     let data = pipe.fileHandleForReading.readDataToEndOfFile()     let output = String(data: data, encoding: .utf8)!     return output   } } and my Package file looks something like that       name: "CustomSdk",       dependencies: ["CustomSdk-Objc"],       path: "CustomSdk",       exclude: ["Info.plist", "CustomSdk.podspec"],       plugins: [         .plugin(name: "GenerateLocalizer")       ]     ),     .plugin(name: "GenerateLocalizer",         capability: .buildTool(),         dependencies: ["CustomSdk-Objc"]     ) It gets called properly but when want to write files in my "testScript.sh" it only says: Operation not permitted. Anyone got any ideas how to fix this or is there another way to utitlize custom scripts with custom packages? Greetings Ben
Posted
by
Post not yet marked as solved
2 Replies
2.8k Views
I'm installing texturepacker in ci_post_clone.sh script using below command in Xcode Cloud workflow. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null brew install --cask texturepacker But I'm getting sudo warning in log. ==> Downloading https://www.codeandweb.com/download/texturepacker/6.0.2/TexturePacker-6.0.2.dmg ==> Installing Cask texturepacker sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required ==> Purging files for version 6.0.2 of Cask texturepacker Error: Permission denied @ dir_s_mkdir - /usr/local/Caskroom How can i fix this issue? Any idea or suggestions would be appreciated. Thank You
Posted
by
Post not yet marked as solved
1 Replies
1k Views
Hi all, I am trying to find a way to export the content of a .pages file into .xml format. That can be done saving the file to '09 version and then unzipping and working on the xml file. But I would like to do it also with .iwa files. I am trying to find a workaround to translate pages file on windows platform without need to pass through word extension, or the '09 format (in order to reduce DTP at its minimum). I am coding on Python... Thank you so much for any suggestion!
Posted
by
Post not yet marked as solved
0 Replies
640 Views
Hello, while I can install VPP app on idevice with Apple Configurator, I can not find a way to do the same thing via cfgutil. Apple configurator registers device's serial number and installs app. While cfgutil only installs app and do not registers serial number. Does cfgutil support installing VPP apps?
Post marked as solved
1 Replies
548 Views
Using the highly-rated answer from StackOverflow How to send an imessage text with applescript, only in provided service?: on run {targetBuddyPhone, targetMessage} tell application "Messages" set targetService to 1st service whose service type = iMessage set targetBuddy to buddy targetBuddyPhone of targetService send targetMessage to targetBuddy end tell end run On Ventura, this errors at save with "Expected class name but found identifier." and highlights the first instance of "service". How should the script be corrected? Is there a difference in grammar between releases? This code works on Big Sur.
Posted
by
Post not yet marked as solved
4 Replies
651 Views
I have an app on my mac that generates an html file. There are different versions of this file. When the file is generated, Folder Actions triggers a bash script that uploads the file to my web site. This version of the file is wacked. I need to identify this file so I can upload a replacement instead. This version can be identified by the presence of the word JazzKnob. Grep can't find this text. Sed doesn't work either. Neither does awk. How can I successfully identify this file? nowplaying.html
Posted
by
Post not yet marked as solved
0 Replies
539 Views
AppleScript code: tell process "EdgeMonitor" tell menu bar 2 UI elements end tell end tell When trying to access UI elements for a given application, we are getting different results on macOS Ventura and macOS Big Sur for the same app and same script. We are specifically trying to access the popover UI element which is accessible in Ventura but not in Big Sur. Can someone please help here to check why this might be happening? Thank you UI elements in macOS Ventura: menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", pop over 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events" UI elements in macOS Big Sur: menu bar item 1 of menu bar 2 of application process "EdgeMonitor" of application "System Events", menu bar item 2 of menu bar 2 of application process "EdgeMonitor" of application "System Events"
Posted
by
Post not yet marked as solved
2 Replies
1.5k Views
Hello guys, I was able to get code coverage and sonar-scanner working with Xcode Cloud. First in, in post-clone script I install sonar-scanner tool like this brew install sonar-scanner Then, in post-xcodebuild script, I do three things: (a) get current app version, (b) get app version, (c) run xcodebuild again with forced code coverage reporting, (d) find coverage data and convert it to the format that Sonarqube understands, and finally (e) run sonar-scanner, which uploads results to Sonarqube dashboard. cd $CI_WORKSPACE # declare variables SCHEME=[REMOVED] PRODUCT_NAME=[REMOVED] WORKSPACE_NAME=${PRODUCT_NAME}.xcworkspace APP_VERSION=$(sed -n '/MARKETING_VERSION/{s/MARKETING_VERSION = //;s/;//;s/^[[:space:]]*//;p;q;}' ./${PRODUCT_NAME}.xcodeproj/project.pbxproj) # clean, build and test project xcodebuild \ -workspace ${WORKSPACE_NAME} \ -destination 'platform=iOS Simulator,name=iPad (10th generation),OS=latest' \ -scheme ${SCHEME} \ -derivedDataPath DerivedData/ \ -enableCodeCoverage YES \ -resultBundlePath DerivedData/Logs/Test/ResultBundle.xcresult \ clean build test # find profdata and binary PROFDATA=$(find . -name "Coverage.profdata") BINARY=$(find . -path "*${PRODUCT_NAME}.app/${PRODUCT_NAME}") # check if we have profdata file if [[ -z $PROFDATA ]]; then echo "ERROR: Unable to find Coverage.profdata. Be sure to execute tests before running this script." exit 1 fi # extract coverage data from project using xcode native tool xcrun --run llvm-cov show -instr-profile=${PROFDATA} ${BINARY} > sonarqube-coverage.report # run sonar scanner and upload coverage data with the current app version sonar-scanner \ -Dsonar.projectVersion=${APP_VERSION} It all works fine but my team and I think that this is a workaround that shouldn't work like this, because technically xcodebuild command is executed two times, first by Xcode Cloud, then by my script, which takes a lot of time and feels hacky. Ideally, Xcode Cloud's Build and Test actions should generate code coverage (the option is already enabled in our project) and give us access to profile data in DerivedData folder which I can access with environment variable CI_DERIVED_DATA_PATH. However, there is none. My question is, do I do everything correctly? Is there a way to improve this flow? Do I miss on how to correctly get code coverage data from Xcode Cloud?
Posted
by
Post not yet marked as solved
0 Replies
613 Views
This is a very long battle trying to solve an issue with an automation I created in the Shortcuts app. I have been facing this issue on my old phone SE2 and now it's the same on my 12. I am running IOS 16.5.1 with the latest security patches/ updates. This issue has also been reported to apple support multiple times with no solution yet. I have tried restoring, deleting all apps., redownloading the Shortcuts app., Deleting the Siri Voices and redownloading them but nothing is helping! I have included Screen and Video recording for this issue for the benefit of the reader I am also explaining the problem/ challenge here in text. NOTE: I am also a VoiceOver user and have a sight impairment Created a personal automation on the Shortcuts app. When any of 2 alarms is topped, get weather, text and speak text. While creating the automation and running it to test, the automation works flawless and the Siri voice used to speak text sounds just like it should. This is covered in the first video link. The challenge: When the automation is triggered, i.e. when the alarm is stopped and the text is to be spoken; the Siri voice is all choppy and inconsistent. This is demonstrated in the second video. P.S. It happens with all English Siri voices irrespective of Language selected in the automation i.e. Australia, India, United Kingdom, United States etc. NOTE: It's the Siri voices I downloaded from: Settings/ accessibility/ Spoken content. Other voices downloaded work fine but they aren't as good and natural as Siri voices. automation how it should be working: https://www.youtube.com/watch?v=-7YxOVRf8WA automation how it works when triggered: https://www.youtube.com/watch?v=rq2rIJQV7cw&amp;list=PL8vG-Fmt9t_lLgPAxlA8qaKVksgc9b3y6&amp;index=2
Posted
by
Post not yet marked as solved
1 Replies
526 Views
We have our own root CA that is installed with our application. For non-MDM installs, the system asks if the user wants to do that, which is all well and good. It also used to ask us when removing that certificate. It doesn't now. So now I am wondering if I dreamed it, except other people say they also got prompted and don't now. It's being installed and removed using the security command, in scripts.
Posted
by
Post not yet marked as solved
0 Replies
429 Views
I get the error code: System Events got an error: Can't get application of "Application Name" during this line repeat with currentWindow in every window of application foregroundApp of this code on run tell application "System Events" set foregroundApps to displayed name of (every process whose background only is false) as list repeat with foregroundApp in foregroundApps set appName to foregroundApp as text if exists (window 1 of process appName) then repeat with currentWindow in every window of application foregroundApp end repeat end if end repeat end tell end run I'm guessing I'm missing something like set x to foregroundApp as y repeat with currentWindow in every window of application x How do I get the windows of the application foreground app?
Posted
by
Post not yet marked as solved
1 Replies
444 Views
So nowadays my MacOS software uses an installer (http://s.sudre.free.fr/Software/Packages/about.html Packages) and it is able to correctly install the application. My client needs to have a quiet installer because he needs to install the app in a large number of computers so using the interactive mode is not good. I am trying to create a script to do that but I am facing the Read-only file system error. Of course my script runs as root. I tried creating a simple Swift code to check, I got the same. So my question: why an installer such Packages can create the folder into the /System/Applications and copy the required files as it runs at the same level of the script and my test program and them don't have the same permission?
Posted
by
Post not yet marked as solved
2 Replies
1k Views
I am working on a Unity IOS game. I keep getting this reoccurring issue. I downloaded XCODE via the app store, so it automatically is in my applications folder Here is the log: Showing Recent Messages WorkingDir: /Users/parkerbrandt/Library/Developer/Xcode/DerivedData/Unity-iPhone-gsxoxmhunhavroeddecygwafmdgn/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/artifacts/arm64/buildstate ExitCode: 4 Duration: 0s13ms ExitCode: 1 Duration: 0s1ms Build failed with 0 successful nodes and 0 failed ones Error: Internal build system error. BuildProgram exited with code 1. Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Mac, you must have Xcode installed. Building for Apple Silicon requires Xcode 9.4 and Mac 10.12 SDK. Xcode needs to be installed in the /Applications directory and have a name matching Xcode*.app. Or be selected using xcode-select. It's also possible to use /Library/Developer/CommandLineTools if those match the listed requirements. More information and installation instructions can be found here: https://developer.apple.com/support/xcode/ Specific Xcode versions can be downloaded here: https://developer.apple.com/download/more/ Unable to detect any compatible iPhoneOS SDK! at Unity.IL2CPP.Bee.BuildLogic.iOS.iOSBuildLogic.GetCompatibleXcodeInstallation(Architecture architecture, Version xcodeMinVersion, Version platformSdkMinVersion, Identifier platformSdkIdentifier, XcodePlatformSdk&amp; compatiblePlatformSdk, XcodeInstallation&amp; compatibleXcodeInstallation) at Unity.IL2CPP.Bee.BuildLogic.iOS.iOSBuildLogic.UserAvailableToolchainFor(Architecture architecture, NPath toolChainPath, NPath sysRootPath) at Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.BuildProgram.Main(String[] args, String currentDirectory) at Unity.IL2CPP.Building.InProcessBuildProgram.StartImpl(String workingDirectory, String[] arguments) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Building/InProcessBuildProgram.cs:line 51 Error: Unity.IL2CPP.Building.BuilderFailedException: Build failed with 0 successful nodes and 0 failed ones Error: Internal build system error. BuildProgram exited with code 1. Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Mac, you must have Xcode installed. Building for Apple Silicon requires Xcode 9.4 and Mac 10.12 SDK. Xcode needs to be installed in the /Applications directory and have a name matching Xcode*.app. Or be selected using xcode-select. It's also possible to use /Library/Developer/CommandLineTools if those match the listed requirements. More information and installation instructions can be found here: https://developer.apple.com/support/xcode/ Specific Xcode versions can be downloaded here: https://developer.apple.com/download/more/ Unable to detect any compatible iPhoneOS SDK! at Unity.IL2CPP.Bee.BuildLogic.iOS.iOSBuildLogic.GetCompatibleXcodeInstallation(Architecture architecture, Version xcodeMinVersion, Version platformSdkMinVersion, Identifier platformSdkIdentifier, XcodePlatformSdk&amp; compatiblePlatformSdk, XcodeInstallation&amp; compatibleXcodeInstallation) at Unity.IL2CPP.Bee.BuildLogic.iOS.iOSBuildLogic.UserAvailableToolchainFor(Architecture architecture, NPath toolChainPath, NPath sysRootPath) at Unity.IL2CPP.Bee.IL2CPPExeCompileCppBuildProgram.BuildProgram.Main(String[] args, String currentDirectory) at Unity.IL2CPP.Building.InProcessBuildProgram.StartImpl(String workingDirectory, String[] arguments) in /Users/bokken/build/output/unity/il2cpp/Unity.IL2CPP.Building/InProcessBuildProgram.cs:line 51 at il2cpp.Program.DoRun(TinyProfiler2 tinyProfiler, String[] args, RuntimePlatform platform, Il2CppCommandLineArguments il2CppCommandLineArguments, BuildingOptions buildingOptions, Boolean throwExceptions) in /Users/bokken/build/output/unity/il2cpp/il2cpp/Program.cs:line 319 Command PhaseScriptExecution failed with a nonzero exit code
Posted
by
Post not yet marked as solved
4 Replies
1.1k Views
Hi, not sure if this forum is the right place to ask, but it’s extremely difficult to search the web for answers about shortcuts.app (must be the name…). I’m learning python currently and I’m trying to automate recurring tasks on my Mac easily. I have a python script as a first test-case that works (It basically makes a bunch of named folders). I use Apples Shortcuts.app to execute the python-file with the shell-script action. I start this script in Finder from the Quick Actions menu. The script creates my folders, but not in the selected folder when executing it, but always in my users home folder /Users/markus/. I suspect I have to somehow tell the Shortcut to take the currently selected folder as a variable or something. I tried to read the help but I don’t find anything useful and don’t understand the options of the Shell-Script Action in Shortcuts.app. Any ideas how I can get this to work? Or does anyone have a link to a good forum to ask questions about Shortcuts.app and automation? Thanks! Regards Markus
Posted
by