views:

66

answers:

2

Hi,

I'm trying to applescript XCode into building and launching on device. My script is as follows:

tell application "Xcode"
    open "tmp:iphone:Guidepal:Guidepal.xcodeproj"
    tell project "Guidepal"
        clean
        build
        launch
    end tell
end tell

My project consists of two targets, MainTarget and a SideTarget, the SideTarget is added as a direct dependency of MainTarget. I noticed that when my applescript runs on a pre-cleaned project (removing the build folder) only 65 files are compiled compared to when I press the "Build & Run" button in XCode 130 files are compiled.

The "launch" command in the script seems to be ignored when running the applescript - it simply does not launch on the device. The status in the bottom bar when the script is complete is "Build succeeded". What is the difference between "build" followed by "launch" compared to pressing the "Build & Run" button in the XCode top bar?

The project launches fine on device when building and running through XCode.

My main issue is that I can't get the applescript to launch on device. I do not know where things go wrong. Has anyone successfully scripted XCode to launch on device?

A: 

build and build and run are two separate commands within Xcode's GUI (v3.1.4 with build and go (run) and build and debug being the remainder). But the Dictionary for Xcode only shows build as being supported via Applescript. I would say both of these commands are the same as they are in the GUI, and in a perfect AS world we would see build and run in the Dictionary to make it more clear.

My question is whether launch is really building the app or just launching the previously built executable.

Philip Regan
launch only launches the built executable if there is one. If the project is cleaned before launch is executed, it does nothing except exits with a "Could not launch executable" error.
Emil Arfvidsson
+1  A: 

I've had this same problem. launch just does not work. You'll have to use debug instead. Also, debug blocks forever, so invoke it with timeout and catch the timeout error and ignore it.

Plumenator