5

I am trying to get Xcode to build and run my project using Applescript. This is the same question as How to build & run Xcode with Applescript?, but I think that answer may be out of date, since it doesn't work on my machine. I get this:

execution error: Xcode got an error: The specified object is a property, not an element. (-10008)

I've also tried the following:

tell application "Xcode"
    build project "MyProject"
end tell

but it doesn't build, it just returns "missing value".

(Using Xcode 4.0.1, OS X 10.6.8)

I've been having a huge amount of trouble trying to use Applescript with Xcode; I can't find any actual documentation (except the Xcode dictionary, which is very terse), just examples that don't seem to work. Any help would be appreciated.

Community
  • 1
  • 1
traversable
  • 740
  • 4
  • 9
  • It may be the same question in theory, but Xcode 3's AppleScript dictionary is vastly different from Xcode 4's, so this is not a duplicate of that question by any means. – NSGod Jul 14 '11 at 01:35

2 Answers2

1

I'm going to venture to guess that this is an incomplete implementation on Apple's part. The Dictionary states that build is supposed to return a value, but nothing is returned and Xcode does nothing. The following code conforms to the Dictionary exactly, but it doesn't work either.

tell application "Xcode"
    set theProject to project 1
    set theBuildConfigType to build configuration type 2 of theProject -- "Debug"
    set projectBuilt to build theProject using theBuildConfigType without static analysis and transcript
end tell

Just for reference here is the syntax per Script Debugger:

set theResult to build reference ¬
     static analysis boolean ¬
     transcript boolean ¬
     using build configuration type
Philip Regan
  • 5,005
  • 2
  • 25
  • 39
0

In Xcode 13, you can do:

tell application "Xcode"
    set theProject to active workspace document
    set actionResult to build theProject
    repeat
        if completed of actionResult is true then
            exit repeat
        end if
        delay 0.5
    end repeat
    set actionResult to run theProject
    repeat
        if completed of actionResult is true then
            exit repeat
        end if
        delay 0.5
    end repeat
end tell
Barry Jones
  • 1,329
  • 1
  • 9
  • 16