Skip to content

clearState command doesn't reliably clear UserDefaults on iOS #1601

@AtomicGeorge

Description

@AtomicGeorge

Describe the bug
Launching an app with clearState or calling clearState directly doesn't reliably clear UserDefaults in an iOS app.

To Reproduce

  1. Write a value to UserDefaults in an iOS app.
  2. Quit the app
  3. Launch an app with maestro using
- launchApp:
    appId: "com.example.app"
    clearState: true

or -clearState followed by -launchApp
4. Observe that UserDefaults still contains the previously written value.
Expected behavior
userDefaults should be cleared and the app should be launched as though it had not been used previously

Environment information (please complete the following information):

  • Maestro version: 1.34.1
  • Platform: iOS 17.0.1
  • Framework: Native iOS
  • Device model and OS version: iPhone 15 iOS 17.0.1
  • Simulator
  • Host: Mac M1

Workspace (if applicable)
MaestroUserDefaultsTestApp.zip

Additional context
A workaround I've found is using -clearState before running launchApp with the clearState option set to true as far as I can tell this should delete everything twice which seems to ensure that the app is fairly reliably launched with a completely clear state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmaestro cliRelated to the command-line Maestro toolplatform: iosTesting iOS apps is affected

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions