Tell AppleScript To Build XCode Project

前端 未结 4 1331
小蘑菇
小蘑菇 2020-12-08 03:09

The following are the steps I would like to have:

  1. launch xcode
  2. open a specific xcodeproj file
  3. build and debug it
  4. quit xcode
相关标签:
4条回答
  • 2020-12-08 03:49

    There's a command line utility called xcodebuild (man page here) which may work better for what you want to accomplish.

    0 讨论(0)
  • 2020-12-08 03:55

    I think I managed to solve it. The following is the AppleScript:

    tell application "Xcode"
        open "Users:chuan:Desktop:iphone_manual_client:iphone_manual_client.xcodeproj"
        tell project "iphone_manual_client"
                clean
                build
                (* for some reasons, debug will hang even the debug process has completed. 
                   The try block is created to suppress the AppleEvent timeout error 
                 *)
                try
                    debug
                end try
        end tell
        quit
    end tell
    

    The path has to be in format of ":" instead of "/". The only problem now is that after the debug console has done its job, AppleScript seems to "hang" as though waiting for something to happen. I need to do more research on AppleScript to know what is wrong with the script.

    0 讨论(0)
  • 2020-12-08 03:55

    I'm not sure about AppleScript but you can compile it from command line, without opening xcode ide, like this:

    xcodebuild -configuration Debug -target WhatATool -project WhatATool.xcodeproj
    

    Where configuration is obvious option, target is the name in Target list of xcode and the project name at the end.

    0 讨论(0)
  • 2020-12-08 03:57

    Since debugging can take an arbitrary amount of time, you probably want a "with timeout of seconds" / "end timeout" block around the debug message.

    0 讨论(0)
提交回复
热议问题