Member-only story
How to Set the Time Zone in Xcode Simulator Using the TZ Environment Variable
When working with the Xcode Simulator, time zone discrepancies can occasionally cause issues, for example you can see difference in your computer system time and time in the simulator or Xcode Preview.
Thankfully, Xcode allows you to set a specific time zone for your app by configuring the TZ
environment variable in your app's scheme. This approach is helpful for debugging and testing apps in different time zones without changing your macOS system settings.
Here’s a step-by-step guide to configure and resolve time zone issues in the Xcode Simulator. At the end we will also disclose a simple method that allows to check currently set timezone.
Step-by-Step Guide to Set the TZ Environment Variable in Xcode
1. Open Your Xcode Project
- Launch Xcode and load the project you want to configure.
2. Edit the Scheme
- Select the scheme for your app and click Edit (the pencil icon).
- This opens the Scheme Editor.
3. Navigate to the Environment Variables Section
- In the left sidebar, select Run under the…