簡體   English   中英

從其他應用程序/命令行/ Apple腳本運行Xcode

[英]Xcode Run from Other App / Command Line / Apple Script

是否可以在后台使用Xcode,但可以通過Script編譯並運行當前項目?

我主要使用AppCode進行開發,但想通過熱鍵從Xcode運行。 AppCode不能正確顯示編譯進度條(可以在第二個屏幕上顯示Xcode),而且AppCode的調試功能不如Xcode先進。 否則,AppCode會更快更好。

可以從AppleScript中獲得以下示例腳本(已在SierraXcode版本8.3.3上測試):

tell application "Xcode"
    tell active workspace document to if exists then
        repeat until (loaded) -- Whether the workspace document has finished loading after being opened
            delay 1
        end repeat
        run -- Invoke the "run" scheme action
    end if
end tell

要在特定設備上運行 :我沒有要測試的設備,但是我使用模擬器,請嘗試以下腳本:

tell application "Xcode"
    tell active workspace document to if exists then
        repeat until (loaded) -- Whether the workspace document has finished loading after being opened
            delay 1
        end repeat
        --**** run on a specific device ****
        set active run destination to run destination "iPad Pro (12.9 inch)" -- *** change it to the name of your device  ***

        set schAction to run -- Invoke the "run" scheme action
        repeat while (get status of schAction) is in {not yet started, running} -- exit the loop when the status is (‌cancelled, failed, ‌error occurred or ‌succeeded), so I press the stop button in Xcode, or I delete the application in the simulator or I quit the simulator.
            delay 3
        end repeat

        --**** run on another specific device ****
        set active run destination to run destination "iPhone 7" -- *** change it to the name of your device  ***
        run
    end if
end tell

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM