Search code examples
xcodeapplescript

How do I get Xcode to build and run using Applescript?


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.


Solution

  • 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