NSUserDefaults + iPhone Transfer Issues

Hi! I was wondering if anyone else encountered similar issues and what the solution ended up being.

We're encountering weird sign-in issues on our iOS version of our app. It seems like an uninstall and reinstall solves it, but the issue seems to only impact users who underwent the transfer process from one iOS device to another. What I am curious about:

  • What is copied over from one device to another in this process?
  • Is there a way outside of owning multiple test devices to replicate this flow?
  • Our current suspicion is that NSUserDefaults is not being cleared by our app on first start, and that stale data is copied over during this transfer process, breaking the sign-in until a re-install wipes everything properly.

Does it seem like we're on the right track with this assumption, or completely out to lunch?

Answered by DTS Engineer in 832316022

To be clear, we’re talking about the Quick Start feature, as described by Use Quick Start to transfer data to a new iPhone or iPad. If not, lemme know.

Written by Atridad in 778806021
What is copied over from one device to another in this process?

It’s hard to give a definitive list but:

  • The bulk of your container is transferred.

  • That includes the files that hold the UserDefaults database.

  • It doesn’t including disposable things, like temporary and cache files.

Written by Atridad in 778806021
Is there a way outside of owning multiple test devices to replicate this flow?

Not really. There are things you can try, but it’s hard to guarantee that they’ll yield exactly the same state. The only way to be sure is to do the same thing that your users are doing.

If you don’t have a second device handy, you could:

  • Use Xcode’s container support to download and then replace the app’s container.

  • Make a password protected local backup of the device, erase it, then restore from that.

And hey, even if these don’t replicate the failure, they’re user scenarios that you should confirm work (-:

Written by Atridad in 778806021
Our current suspicion is that NSUserDefaults is not being cleared by our app on first start

Who do you suppose should be clearing it?

As mentioned above, I wouldn’t expect a Quick Start transfer to clear UserDefaults.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

To be clear, we’re talking about the Quick Start feature, as described by Use Quick Start to transfer data to a new iPhone or iPad. If not, lemme know.

Written by Atridad in 778806021
What is copied over from one device to another in this process?

It’s hard to give a definitive list but:

  • The bulk of your container is transferred.

  • That includes the files that hold the UserDefaults database.

  • It doesn’t including disposable things, like temporary and cache files.

Written by Atridad in 778806021
Is there a way outside of owning multiple test devices to replicate this flow?

Not really. There are things you can try, but it’s hard to guarantee that they’ll yield exactly the same state. The only way to be sure is to do the same thing that your users are doing.

If you don’t have a second device handy, you could:

  • Use Xcode’s container support to download and then replace the app’s container.

  • Make a password protected local backup of the device, erase it, then restore from that.

And hey, even if these don’t replicate the failure, they’re user scenarios that you should confirm work (-:

Written by Atridad in 778806021
Our current suspicion is that NSUserDefaults is not being cleared by our app on first start

Who do you suppose should be clearing it?

As mentioned above, I wouldn’t expect a Quick Start transfer to clear UserDefaults.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you so much for the reply!

Written by DTS Engineer in 832316022
Who do you suppose should be clearing it?

I meant more on our end, whether deleting this could sort things out. I think this actually helps quite a bit though. I'll see what else I can find with these pointers. Thanks!

NSUserDefaults + iPhone Transfer Issues
 
 
Q