Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AtomicGeorge opened this issue Nov 22, 2023 · 3 comments
Open

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

AtomicGeorge opened this issue Nov 22, 2023 · 3 comments
Labels
bug Something isn't working maestro cli Related to the command-line Maestro tool platform: ios Testing iOS apps is affected

Comments

@AtomicGeorge
Copy link

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.

@AtomicGeorge AtomicGeorge added the bug Something isn't working label Nov 22, 2023
@brandenbyers
Copy link

I'm seeing this same issue. The above workaround does not work for my use case. clearKeychain nor clearState clear the state like they do on Android. The only workaround that I have found is to use xcrun to uninstall and reinstall the app.

@bartekpacia bartekpacia added platform: ios Testing iOS apps is affected maestro cli Related to the command-line Maestro tool labels Jul 12, 2024
@bartekpacia bartekpacia changed the title clearState doesn't reliably clear UserDefaults on iOS clearState command doesn't reliably clear UserDefaults on iOS Jul 12, 2024
@Losiowaty
Copy link

@brandenbyers @AtomicGeorge
Folks, do you by chance use shared user defaults (in an app group)?

What I've found is that running the idb command found in clearState docs (here) does clean the "regular" UserDefaults just fine, but doesn't touch the shared ones.

@AtomicGeorge
Copy link
Author

@brandenbyers @AtomicGeorge Folks, do you by chance use shared user defaults (in an app group)?

What I've found is that running the idb command found in clearState docs (here) does clean the "regular" UserDefaults just fine, but doesn't touch the shared ones.

@Losiowaty The example project just uses standard user defaults, no sharing or anything fancy at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maestro cli Related to the command-line Maestro tool platform: ios Testing iOS apps is affected
Projects
None yet
Development

No branches or pull requests

4 participants