2017-09-01 149 views
0

是否可以在後臺使用Xcode,但通過腳本編譯並運行當前項目?從其他應用程序/命令行/ Apple腳本運行Xcode

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

回答

1

有可能從一個AppleScript,這裏有一個示例腳本(上測試塞拉利昂的Xcode版本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 
+0

W這是快速的,它很棒!謝謝!你偶然也知道在特定設備上運行?我正在製作一個實時多人遊戲,我經常需要在兩臺設備上運行。在一臺設備上運行會很酷,等到完成後再運行。 – keyboard