1

I am developing natives apps for both Android and iOS and when debugging some login scenarios I need to reset the app to its initial stage without any token persisted on the (virtual) device. On Android, it is just as easy as typing an adb commande adb shell pm clear my.app.package.

Is there a way on iOS or shall I go through the lengthy process of uninstalling and re-installing the app ?

1

On iOS, erase all content and settings is how you wipe everything and then push your app again.

xcrun whatever....

The above xcrun is just useful to install and run an app as opposed to what you want which is to manage settings. See this developer article - at the very end it explains your settings persist even with app removal - so you’d need to clean on the simulator or write your app to reset settings with specific code.

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html#//apple_ref/doc/uid/10000059i-CH6-SW5

How effective these three options is really depends on your specific code, however. Erase all content always works.

  • Thanks @bmike, I would like to understand from my mac command line xcrun defaults delete com.my.app will remove my app from the simulator of physical device attache via USB ? Can I mention a device name ? Did not found more than the --help short documentation – Philippe Cohen Jan 17 at 13:43
  • @PhilippeCohen xcrun only installs an app bundle from a script on the mac as opposed to clicking run in Xcode. It automates things you would click in Xcode - not that it opens an ssh / command line to do things. I’m going to revisit the uninstall option after digging up an Apple article explaining that won’t work – bmike Jan 17 at 18:33
  • @bmike Please be aware that you two are talking about two vastly different things. bmike is talking about settings bundles, which is not what you want. The tokens in your app are not persisted in the settings bundle - so even though you could remove the settings bundle, it is not going to achieve what Philippe want. – jksoegaard Jan 17 at 19:15
  • Indeed @jksoegaard I am looking for a way to clean persistent storage created by my react-native app, using different means than setting bundle. In Android this is enabled both from the UI (Clear Storage) and from adb. I do not find any equivalent on iOS – Philippe Cohen Jan 20 at 7:36
  • 1
    @bmike I'll create a new answer when Phillippe supplies the necessary information. I'm an app developer myself and often need to do the same as Phillippe, but how you do it is entirely dependent on how the tokens are stored. However, no one stores tokens in settings bundles - so that's definitely not the way to go. Also "Erase all content and settings" doesn't work on the Simulator at all. On a real device it will delete the tokens ordinarily, but it is not a practical advice as you cannot really do that 20-30 times a day - and you wouldn't want to do it on a device you use for other things. – jksoegaard Jan 20 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .