changing date in iOS simulator

Viewed 23

I want to change the date in the iOS simulator, the simulator doesn't have the option in the settings section of the simulator. it must be done through Xcode itself?

1 Answers

The simulator is basically a macOS process running on your host system, therefore it doesn't have its own date and time, it rather uses the system date.

If you need to change the date in order to test how your app would work on a certain date in the past or in the future, you're better off using mocks for that. For example, if a certain function performs some date based calculation and figures the current date by calling Date(), better pass that date as a parameter.

If you need a different date in the simulator for the screenshotting purposes, look into the xcrun simctl status_bar command, it allows to override the date and time in the status bar (the system date and time will not be affected by that).

Related