如何在构建时自动重置iPhone模拟器 [英] How to automatically reset iPhone simulator on build
问题描述
将多个JSON文件从应用程序包根目录移动到目录结构(也在应用程序包中)后,应用程序一直在运行,就像文件保留在其先前位置一样。经过多次头脑清理和干净的构建后,我记得必须清除iPhone模拟器才能摆脱旧位置的这些文件。
After moving several JSON files from the app bundle root to within a directory structure (also in the app bundle) the app kept running as if the files remained in their prior location. After much head scratching and doing a clean build I remembered that the iPhone simulator had to be cleared out in order to get rid of these files in the old locations.
它'我一定很高兴能够在每次构建时强制重置模拟器。清洁平板模式,如果你愿意的话。这可以以任何方式被黑客攻击吗?有什么想法吗?
It'd sure be nice to have the option to force a reset of the simulator on every build. Clean-slate mode, if you will. Can this be hacked in any way? Any ideas?
推荐答案
你可以为运行的预先行动添加新运行脚本动作你的方案的一步来运行将重置模拟器的AppleScript。
You can add a "New Run Script Action" to the "Pre-actions" for the "Run" step of your scheme to run AppleScript that will reset the simulator.
首先将shell设置为/ usr / bin / osascript
First set the shell to /usr/bin/osascript
然后在输入脚本区域中输入以下内容:
Then enter the following in the "type a script" area:
#!/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
这篇关于如何在构建时自动重置iPhone模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!