xcode 重置 iOS 模拟器应用程序数据以首次运行应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16195859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reset iOS Simulator application data to run app for first time
提问by user2301717
I just finished writing some code that checks if it is the first time the app is running then display a message, if it is not the first time then display another message..
我刚刚写完一些代码,检查应用程序是否第一次运行然后显示一条消息,如果不是第一次则显示另一条消息..
How do you reset the simulator on Xcode so that I can test the app when it runs the first time?
你如何在 Xcode 上重置模拟器,以便我可以在第一次运行时测试应用程序?
I tried cleaning the build folder but it didn't work..
我尝试清理构建文件夹,但没有用。
回答by Tim
In the iOS Simulator, press iOS Simulatorin the menu at the top of the screen, and press 'Reset Content and Settings...'. This will clear the entire simulator.
在iPhone模拟器,按iPhone模拟器在屏幕的顶部,然后按菜单中的“重置内容和设置...”。这将清除整个模拟器。
Or, on the home screen of the simulator, uninstall the app in the same way you would on a physical device, by pressing and holding on the application icon until an 'x' appears in the top left, and press the 'x', and select 'Delete' from the alert view. This will clear all data associated with a single app.
或者,在模拟器的主屏幕上,以与在物理设备上相同的方式卸载应用程序,按住应用程序图标直到左上角出现“ x”,然后按“x”,并从警报视图中选择“删除”。这将清除与单个应用程序关联的所有数据。
Then do a clean, build and run.
然后进行清理,构建并运行。
回答by Jose Llausas
The correct way to do this in XCode is: (Simulator must be shut down first)
在 XCode 中执行此操作的正确方法是:(必须先关闭模拟器)
xcrun simctl erase <device UDID>
or
xcrun simctl erase all
xcrun simctl erase <device UDID>
或者
xcrun simctl erase all
To find out the UDID use:
要找出 UDID,请使用:
xcrun simctl list
xcrun simctl list
回答by Darius Miliauskas
回答by Stacy Simpson
@Tim's answer is probably easier for interactive usage.
@Tim 的答案可能更易于交互式使用。
We use scripts for automated testing and delete the simulator's data directory to ensure it's clean. The simulator will re-create basic information when it restarts.
我们使用脚本进行自动化测试并删除模拟器的数据目录以确保其干净。模拟器在重启时会重新创建基本信息。
Delete the following:
删除以下内容:
~/Library/Application Support/iPhone Simulator/${simulator.version}
~/Library/Application Support/iPhone Simulator/${simulator.version}
回答by Sandu
Don't really know if this is the best way but following is working for me:
不知道这是否是最好的方法,但以下对我有用:
first kill all working Simulators with
首先杀死所有工作的模拟器
killall Simulator 2>&- && sleep 5 || true
killall Simulator 2>&- && sleep 5 || true
afterwards reset all devices with
然后重置所有设备
xcrun simctl erase all
xcrun simctl erase all
ps.: I'm working with XCode 8
ps:我正在使用XCode 8