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

时间:2022-09-25 19:09:48

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.

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

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?

在每次构建时都可以选择强制重置模拟器,这当然是件好事。清洁平板模式,如果你愿意的话。这可以以任何方式被黑客攻击吗?有任何想法吗?

2 个解决方案

#1


7  

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.

您可以在方案的“运行”步骤的“预执行”中添加“新运行脚本操作”,以运行将重置模拟器的AppleScript。

First set the shell to /usr/bin/osascript

首先将shell设置为/ 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

#2


0  

In Yosemite + iOS Simulator 8.3, It worked when I changed the Vic's strings of "iPhone Simulator" and "iOs Simulator" to "iOS Simulator".

在Yosemite + iOS模拟器8.3中,当我将Vic的“iPhone模拟器”和“iOs模拟器”字符串更改为“iOS模拟器”时,它工作正常。

#1


7  

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.

您可以在方案的“运行”步骤的“预执行”中添加“新运行脚本操作”,以运行将重置模拟器的AppleScript。

First set the shell to /usr/bin/osascript

首先将shell设置为/ 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

#2


0  

In Yosemite + iOS Simulator 8.3, It worked when I changed the Vic's strings of "iPhone Simulator" and "iOs Simulator" to "iOS Simulator".

在Yosemite + iOS模拟器8.3中,当我将Vic的“iPhone模拟器”和“iOs模拟器”字符串更改为“iOS模拟器”时,它工作正常。