2014-03-31 20 views
0

我正在運行依賴於每次運行的乾淨構建的自動UI測試。Pre-Action運行腳本清除模擬器的應用程序支持目錄

我想補充一點,清除出任何的應用程序支持目錄預執行運行腳本(例如/Users/username/Library/Application Support/iPhone Simulator/7.1/Applications/58A5DCF7-689B-4D13-B178-A88CDE33512/Library/Application Support

是否有一個Xcode的變量,可以很容易獲得該目錄?任何像$(BUILD_DIR)?

+0

儘管@ user1041311的答案確實清除了應用程序支持目錄,但它也會強制重新啓動整個模擬器。任何其他人都知道一個變量進入「應用程序支持」目錄的機會? –

回答

1

這裏是什麼對我的作品!

#/斌/慶典

# `menu_click`, by Jacob Rus, September 2006 
# 
# Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}` 
# Execute the specified menu item. In this case, assuming the Finder 
# is the active application, arranging the frontmost folder by date. 

osascript <<SCRIPT 

on menu_click(mList) 
    local appName, topMenu, r 

    -- Validate our input 
    if mList's length < 3 then error "Menu list is not long enough" 

    -- Set these variables for clarity and brevity later on 
    set {appName, topMenu} to (items 1 through 2 of mList) 
    set r to (items 3 through (mList's length) of mList) 

    -- This overly-long line calls the menu_recurse function with 
    -- two arguments: r, and a reference to the top-level menu 
    tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬ 
     (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu))) 
end menu_click 

on menu_click_recurse(mList, parentObject) 
    local f, r 

    -- `f` = first item, `r` = rest of items 
    set f to item 1 of mList 
    if mList's length > 1 then set r to (items 2 through (mList's length) of mList) 

    -- either actually click the menu item, or recurse again 
    tell application "System Events" 
     if mList's length is 1 then 
      click parentObject's menu item f 
     else 
      my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f))) 
     end if 
    end tell 
end menu_click_recurse 

application "iPhone Simulator" activate  
menu_click({"iPhone Simulator", "iOS Simulator", "Reset Content and Settings…"}) 

tell application "System Events" 
    tell process "iPhone Simulator" 
     tell window 1 
      click button "Reset" 
     end tell 
    end tell 
end tell 

SCRIPT 

來自https://stackoverflow.com/a/14811280/1041311

還要注意,首次書呆子的工作,因爲你需要允許Xcode修改文件夾。在第一次運行時會出現一個對話框,它會將您帶到系統首選項,您需要爲Xcode授予權限。

+0

太棒了,這個作品很棒。謝謝 :-) – dKrawczyk

相關問題