gpt4 book ai didi

ios - Pre-Action运行脚本以清除模拟器的Application Support目录

转载 作者:行者123 更新时间:2023-11-29 03:06:00 25 4
gpt4 key购买 nike

我正在运行自动化 UI 测试,该测试依赖于每次运行的干净构建。

我想添加一个预操作运行脚本,以清除应用程序支持目录中的所有内容(例如 /Users/username/Library/Application Support/iPhone Simulator/7.1/Applications/58A5DCF7-689B- 4D13-B178-A88CDE33512/库/应用程序支持)

是否有 Xcode 变量可以轻松访问该目录?类似于 $(BUILD_DIR) 的东西吗?

最佳答案

这是对我有用的:

#!/bin/bash

# `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 授予该权限。

关于ios - Pre-Action运行脚本以清除模拟器的Application Support目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22764863/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com