Search code examples
iosxcodensuserdefaultsplistxcode9.3

How to check [NSUserDefaults standardUserDefaults] in iOS development device with Xcode 9.3


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?


Solution

  • 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