maestro
maestro copied to clipboard
`clearState` command doesn't reliably clear UserDefaults on iOS
Describe the bug
Launching an app with clearState or calling clearState directly doesn't reliably clear UserDefaults in an iOS app.
To Reproduce
- Write a value to
UserDefaultsin an iOS app. - Quit the app
- 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.