9

When running an app on the iPhone (for example when you can do it in another way testing some GPS or camera feature), where can I find and check the file created by NSUserDefaults to save the standardUserDefaults ? I'm running XCode 4.

James Webster
  • 31,873
  • 11
  • 70
  • 114
Oliver
  • 23,072
  • 33
  • 138
  • 230
  • 1
    Who says it's in a file? And why does it matter? There's an API to access the values. How it's implemented should make no difference. – Stephen Darlington Mar 23 '11 at 10:32
  • 3
    @Stephen Darlington : It's for easier debug and to see what is really recorded regarding to the original plist given. – Oliver Mar 23 '11 at 11:26
  • This will give you the location in Swift 3.1: print(NSHomeDirectory()) – Bobby Jun 01 '17 at 10:18

3 Answers3

21

It's in your app directory under:

Library -> Preferences -> bundleID.plist

You can access the data on your device. Go into the organizer select your device then the app and there should be a download button there. If you click that it will download all the app data.

jose920405
  • 7,982
  • 6
  • 45
  • 71
rckoenes
  • 69,092
  • 8
  • 134
  • 166
6

The user defaults file for applications started in the simulator are located here:

/Users/[USERNAME]/Library/Application Support/iPhone Simulator/4.3/Applications/[UNIQUE IDENTIFIER]/Library/Preferences/APP_ID.plist

The USERNAME is the user you run as on your system.

The UNIQUE IDENTIFIER is generated by Xcode.

APP_ID is your com.yourcompany.app bundle id.

clawoo
  • 791
  • 6
  • 14
  • @Oliver: This is what you asked for. – rckoenes Mar 23 '11 at 12:13
  • Yes I did, but since you can't access the application bundle from your device from your Mac, I gave you a solution for the Simulator. I suppose you could try to read the contents of the plist from your device using [NSDictionary dictionaryWithContentsOfFile:] and figuring out the path to the Library/Preferences/APP_ID.plist file. – clawoo Mar 23 '11 at 12:28
  • 4
    You can access the data ion your device. Go into the organizer selected te your device then the app and there should be a download button there. If you click that it will download all the app data. – rckoenes Mar 23 '11 at 13:01
  • @rckoenes : rckoenes, you Rockkkk !Coudl you please post your comment as an answer as I could accept it ? – Oliver Mar 23 '11 at 23:59
0

You can see it in:

/var/mobile/Containers/Data/Application/F27682C5-55AC-4984-9864-313DA609134F/Library/Preferences while App at: /var/mobile/Containers/Bundle/Application/AE02FFCA-4CAF-4B58-8F32-0D67A78BD259

jose920405
  • 7,982
  • 6
  • 45
  • 71
swigger
  • 311
  • 2
  • 7