How do I set the system time for XCode UI tests?

I need to be able to set the system time on the simulator when I do unit/ui tests in XCode. I tried doing “sudo date 0410125516” in a script step in my workflow, but doing so messed up the run timer: “Invalid time box size for RunTime: -28782392495010873”

1 Like

Hi @bruce-lumo,

Although you are able to change the system time, but you should never do that. It will cause lots of trouble, will make it pretty much impossible to run it locally on your Mac/PC and web services tend to reject upload & download requests when the time is not in sync.

You should either:

  1. Make your tests to not to depend on the time.
  2. Or make your tests to “mock” / set / simulate the time you want. Something like this:

If you have any questions, just let us know!

Happy Building! :robot: