6

In Xcode 9.3 and iOS simulators, [NSUserDefaults standardUserDefaults] store the values at:

/Users/{User Name}/Library/Developer/CoreSimulator/Devices/{Device GUID}/data/Containers/Data/Application/{application GUID}/Library/Preferences/{bundle identifier}.plist

where I could open the .plist file easily and look into the values.

But, how could I check these values when the app is running in a development device? Is it possible to check these values in a developed device like as simulators?

Krunal
  • 77,632
  • 48
  • 245
  • 261
Simant
  • 3,142
  • 4
  • 32
  • 61
  • 2
    Is there any particular reason to open the PList directly instead of just using `NSUserDefaults`? If you just need to see what's stored, using `dictionaryRepresentation()` would give you everything: `for (key, value) in UserDefaults.standard.dictionaryRepresentation() { print("\(key) = \(value)") }` – Alejandro Iván May 16 '18 at 14:27
  • 1
    @Krunal Yes, this solved my problem. Thanks – Simant May 28 '18 at 09:13

1 Answers1

8

You cannot access it directly. Apple does not allow, an access to such kind of data (and/or files) of iOS application (for any external sources) from device.

Only application developer can access it programatically. (There are some software available in market, which can open/access files from IPA using Jail-broken devices.)

Refer this Apple document: iOS Security - File Data Protection. (There is no direct answer to your question but complete details about file and data security, in this doc.)

But if you are a developer of this app then you can find it from AppData Preferences.

Follow these steps to find it:

  1. Open Device and Simulator window (Xcode (Menu) >> Window >> Devices and Simulators).
  2. Select your iOS device from a list of connected devices.
  3. Select an apps from a list of Installed Apps.
  4. Click on application Settings icon
  5. Select Download Container, that will prompt you to save you file.
  6. Save your file (file extension - .xcappdata)

enter image description here

  1. Right click on file and select Show Package Contents

enter image description here

  1. A finder window will show a path to AppData of file.
  2. Go to: AppData >> Library >> Preferences >> <file>.plist
  3. Bingo: This is what you are looking for. UserDefault storage file. Open it and check your data.

enter image description here

Krunal
  • 77,632
  • 48
  • 245
  • 261
  • 1
    Sorry but this answer is incorrect - at least when it comes to an app your are developing. – rmaddy May 16 '18 at 14:47
  • 2
    Thanks! This worked for me for my real development device. I was able to read the UserDefaults file using Xcode 11.4.1. – Bruno Bieri May 20 '20 at 09:08
  • 1
    confirmed, this worked for viewing UserDefaults file downloaded from actual device. Crazy how many steps it requires just to view a snapshot. – cevaris Jul 15 '21 at 02:19