I need an AppleScript that opens an Xcode project and duplicates its last target.
I've found some answers here and there but none of them seem to work (at least with Xcode 9.1).
I've tried this:
do shell script "open <myproject>"
tell application "Xcode"
tell active workspace document
tell first project
duplicate last target
end tell
end tell
end tell
But it fails with:
execution error: Error in Xcode: Can not set last target of project 1 of active workspace document to last target of project 1 of active workspace document. (-1006)
How would you do that?