2

I have an app I've made for a customer which stores certain information in NSUserDefaults and it all works between sessions using the app. But when the user updates the app the NSUserDefaults gets cleared. As far as I can tell the NSUserDefaults should NOT clear on updates - only on uninstalls. I can't for the life of me figure out why or how to adress this issue.

My app is written in Swift 2.0, supporting iOS 8 and upwards, distributed through TestFlight and/or HockeyApp.

ClockWise
  • 1,509
  • 15
  • 32
  • possible duplication of http://stackoverflow.com/questions/1638766/do-nsuserdefaults-persist-through-an-update-to-an-app-in-the-appstore – Witterquick Feb 04 '16 at 09:00
  • and, yes, the userDefaults should be persisted – Witterquick Feb 04 '16 at 09:03
  • Are you possibly (re)setting the NSUserDefaults when the app is launched for the first time ? That might explain why the older values don't persist. – Shivam Bhalla Feb 04 '16 at 09:03
  • first could you please clarify it is a public _update_ via AppStore or only a _new test version_ via TestFlight? – holex Feb 04 '16 at 09:25
  • I will double check the setting of NSUserDefault at first time start, but I'm pretty sure this isn't the issue. I check at launch if the NSUserDefaults has data stored, if it does I load it in and just keep appending to it. If it doesn't exist I will store anew. @holex New test version through TestFlight, not an update through AppStore. – ClockWise Feb 04 '16 at 09:37
  • 7
    @ClockWise, as you probably know that via TestFlight there is no such thing _"update"_, the TestFlight always does a clean install for security reason, regardless an earlier version of the app was/wasn't already on the device – and that includes to clean the `NSUserDefault` as well. – holex Feb 04 '16 at 09:40
  • @holex thanks for your response, I'm not the one actually deploying the app so I'm not sure how TestFlight works, so thanks for clearing this up. Do you know it it's the same thing using Hockey App? – ClockWise Feb 04 '16 at 09:46
  • HockeyApp uses the OTA Ad-Hoc distribution mechanism from iOS. Downloading and installing the app is fully controlled by iOS itself. As far as I know this does not delete all user data prio to installation, but as the specifics on how iOS handles things (even differently in iOS versions) this can not be guaranteed. – Kerni Feb 04 '16 at 09:50
  • @holex - NSUserDefaults should not be erased on TestFlight app update as far as I know. It's not getting deleted for me. – Lubos Feb 04 '16 at 10:48
  • @Lubos, the keychain should not be deleted only. – holex Feb 04 '16 at 11:02
  • @ClockWise Change in entitlement file also cause such kind of issue. https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html – Bhavesh Patel Aug 28 '19 at 17:08
  • @BhaveshPatel Where are you seeing that exactly? – Zoltán Jan 26 '21 at 19:27

0 Answers0