Git Product home page Git Product logo

Comments (1)

funnel20 avatar funnel20 commented on June 8, 2024

Sorry, this is a duplicate of #21464

However, I figured it out and have a work-around.

Analysis

When using override_status_bar true, the console log shows the automatically generated arguments:

$ xcrun simctl status_bar 463A8557-2F51-432A-A880-7EA671F20805 override --time 2007-01-09T09:41:00+01:00 --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100 &> /dev/null

When adding override_status_bar_arguments "--wifiBars 3", the console log shows:

$ xcrun simctl status_bar 4CD9AAB8-AAF8-461D-B077-7815623A2436 override --wifiBars 3 &> /dev/null

The reason why the latter worked, was because my Simulator was already started with Simulator Status Magic enabled.
Using a brand new Simulator, doesn't show the "9:41", but the current time. This clarifies 1 observation.

So the root cause is in the ISO time stamp for parameter --time: 2007-01-09T09:41:00+01:00.
The time zone +01:00 is wrong, since I'm at CEST which has Daylight Saving enabled, so it's currently +02:00.

Work-around

When manually changing the timezone in the arguments in the Snapfile the correct time is displayed in the screenshots:

override_status_bar_arguments "--time 2007-01-09T09:41:00+02:00 --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100"

However, when running Snapshot in winter, it will display the wrong time. Hence made the time zone offset dynamically in the Snapfile with some Ruby code:

require 'active_support/all'    # For `Time.now.formatted_offset()`

devices([
    "iPhone 12 Pro",
    ])

# Get current timezone offset:
timezone_offset = Time.now.formatted_offset(true)
puts("timezone_offset = #{timezone_offset}")               # Optional, to write to Console output

# Override status bar and override arguments incl. timezone offset, as by default it goes wrong with Daylight Saving Time (e.g. shows "10:41" instead of "9:41", see: https://github.com/fastlane/fastlane/issues/22026 )
override_status_bar true
override_status_bar_arguments "--time 2007-01-09T09:41:00#{timezone_offset} --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100"    # For a list of commands, type the following in Terminal: xcrun simctl status_bar --help

Solution

To resolve this in code, the Time object should get the proper time zone information, see:

# The time needs to be passed as ISO8601 so the simulator formats it correctly
time = Time.new(2007, 1, 9, 9, 41, 0)
# If you don't override the operator name, you'll get "Carrier" in the status bar on no-notch devices such as iPhone 8. Pass an empty string to blank it out.
arguments = "--time #{time.iso8601} --dataNetwork wifi --wifiMode active --wifiBars 3 --cellularMode active --operatorName '' --cellularBars 4 --batteryState charged --batteryLevel 100"

from fastlane.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.