如何重置 iPhone 模拟器

我的应用程序使用定位服务。为了测试当模拟器请求访问位置服务的权限时(当应用程序第一次启动时)用户按“不允许”时发生了什么,我需要重置模拟器。这是因为问题在开发过程的开始就得到了回答和允许。所以不要再问问题了。

用“重置内容和设置”重置模拟器。."不要一开始就把问题带回来。我做错了什么?

61332 次浏览

If you're using Snow Leopard:

Go to your mac's System Preferences (not the simulator's), Select the Security section. Hit the "Reset Warnings" button in front of Location Services, you're all set.

For iOS 14 and newer:

Device > Erase All Contents and Settings...

For iOS 11 and newer:

Hardware > Erase All Contents and Settings...

For previous versions:

Simulator > Reset Content and Settings...

(In earlier versions of the simulator the top menu entry label was "iOS Simulator"

Apple says

To set the user content and settings of the simulator to their factory state and remove the applications you have installed, choose iPhone Simulator > Reset Content and Settings.

http://support.apple.com/kb/ht2110

Nice and handy tool. The great Fastlane commandline tools (https://github.com/fastlane/snapshot)

snapshot reset_simulators

reset_simulators is removing all simulators and create new one only for the latest iOS version. If you want to recreate simulators for other versions you have to provide the list of the versions after the --ios argument, e.g.

snapshot reset_simulators --ios 8.3,8.4,9.0,9.1

For iOS 11 and newer, you need to go the top system menu and select:

"Hardware" > "Erase All Contents and Settings..."

I tried "Erase All Content and Settings" in Simulator 10.0, but it didn't work. What worked for me is that in Simulator 10.0, the Settings app is built in. You can reset by:

  1. Clicking on the Settings app to start it.
  2. Click General.
  3. Click Reset.
  4. Click Reset Location & Privacy.
  5. Click Reset Warnings.

Then your authorization status will be reset to .notDetermined.

Or you can choose simctl to manage iOS simulator in Command Line.

$ xcrun simctl erase all is too erase all content in all simulator.

For more information, you can read this blog from XCBlog: https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc

For Xcode 11.4

Device -> Erase All Content and Settings...

Image