簡體   English   中英

有沒有辦法從命令行關閉iOS模擬器?

[英]Is there a way to close the iOS Simulator from the command line?

有什么方法可以通過命令行腳本退出iOS模擬器嗎?

背景:

我正在設置一個持續集成環境,以使iOS版本能夠編譯並自動進行測試。 作為此過程的一部分,我將使用Instruments內的Apple UI自動化工具運行腳本。

現在,我想通過從命令行BUT運行Instruments來自動執行iOS Simulator上的腳本,現在我想自動退出Simulator。

我已經嘗試了一些類似於本文的Apple腳本: 如何從命令行重置iOS模擬器? 但是出現錯誤“輔助設備的訪問已禁用”。 希望有更簡單的方法嗎?

對於Xcode 7+,命令為killall Simulator

終端中的killall "iOS Simulator"將關閉它。

另外,您可以使用iphonesim啟動它,以對其進行更多控制,包括根據需要修改源。

嘗試這個:

osascript -e 'tell app "iOS Simulator" to quit'

將XCode 6的一些命令組合在一起:

killall "iOS Simulator" 

xcrun simctl list | grep Booted | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl shutdown uuid

xcrun simctl list | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl erase uuid

open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app

根據該腳本,您可以這樣創建它:

tell application "iPhone Simulator"
    activate
end tell

tell application "System Events"
    tell process "iPhone Simulator"
        tell menu bar 1
            tell menu bar item "iOS Simulator"
                tell menu "iOS Simulator"
                    click menu item "Quit iOS Simulator"
                end tell
            end tell
        end tell
    end tell
end tell

輔助設備錯誤也會在此發生。 要解決此問題,您需要轉到系統設置,通用訪問權限並選中“啟用輔助設備訪問權限”

暫無
暫無

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

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