如何在构build时自动重置iPhone模拟器

将几个JSON文件从应用程序包根目录移动到目录结构(也在应用程序包中)之后,应用程序保持运行状态,就好像这些文件保留在其之前的位置一样。 经过多次头部划伤和干净的构build,我记得iPhone模拟器必须被清除掉,以摆脱旧位置这些文件。

它肯定会很好,可以select在每个版本上强制重置模拟器。 如果你愿意的话,清理石板模式。 这可以以任何方式被黑客入侵吗? 有任何想法吗?

您可以将“新运行脚本操作”添加到您的scheme的“运行”步骤的“预执行”以运行将重置模拟器的AppleScript。

首先将shell设置为/ usr / bin / osascript

然后在“键入脚本”区域中input以下内容:

#!/usr/bin/env osascript 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 "Reset Content and Settings…" end tell end tell end tell tell window 1 click button "Reset" end tell end tell end tell 

在优胜美地+ iOS模拟器8.3中,当我将Vic的“iPhone Simulator”和“iOs Simulator”改为“iOS Simulator”时,它就起作用了。