Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applescript Xcode to clean, build and install on iPhone device

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

tell application "Xcode"
    open "tmp:iphone:myproject:Project.xcodeproj"
    tell project "Project"
        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?

like image 355
Emil Arfvidsson Avatar asked Feb 07 '26 15:02

Emil Arfvidsson


1 Answers

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.

like image 77
Plumenator Avatar answered Feb 09 '26 11:02

Plumenator



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!