Search code examples
xcodemacosxcode8automator

Automator not working inside xcode


I am running an automator with an applescript, and while it works inside automator, it fails when run from xcode. Here's my code:

tell application "Xcode"
    set targetProjectPath to path of active workspace document
    set targetProjectPath to POSIX file (targetProjectPath & "/..") as string
    set targetProjectPath to POSIX path of targetProjectPath
    tell application "System Events"
        tell process "Xcode"
            click menu item "Save" of menu 0 of menu bar item "File" of menu bar 0
        end tell
    end tell
    return {targetProjectPath}
end tell

I am trying to trigger save and return me the path of the active workspace to do some work later. I just started on it few days back, so pardon me if it's something really stupid.


Solution

  • It was really simple. All I needed was to give xcode access to be able to modify accessibility settings. The code is working perfectly fine.