1

I am developing an IOS (swift) application within a corporate company. The app has a DEV and a PROD version. I install and test both versions on the same iphone device. The bundleIdentifier is applicationNameDev for the dev app, and applicationNameProd for the PROD. However, I have a problem when I run both apps on the same device. I guess the user settings in the DEV application are used in the PROD application. I solve this problem with "Erase all content and settings" option in simulator. But how can i do this on real iphone device. (Without formatting the phone and deleting the data)

NOTE: I deleted and reinstalled both applications but the problem persists.

OmerArslan
  • 364
  • 1
  • 2
  • 14
  • 1
    Does this answer your question? [Delete all keys from a NSUserDefaults dictionary iOS](https://stackoverflow.com/questions/6797096/delete-all-keys-from-a-nsuserdefaults-dictionary-ios) – jnpdx Jan 29 '22 at 20:01
  • No this link did not solve the problem. Still I have same problem – OmerArslan Jan 29 '22 at 20:13
  • 2
    Unless I am mistaken, two applications (with different bundle identifiers) do *not* share any user defaults. – Martin R Jan 29 '22 at 22:20
  • They could share UserDefaults if they had a group container. But, without seeing any of the relevant code here, it's impossible to tell what's really going on. – jnpdx Jan 30 '22 at 02:10

1 Answers1

1

You can create different suits on user defaults based on your target using directives. Check this out: https://developer.apple.com/documentation/foundation/userdefaults/1409957-init

#if PROD
let defaults = UserDefaults(suiteName: "prod")
#else
let defaults = UserDefaults(suiteName: "dev")
#endif