How can I pull the NSUserDefaults shared preferences from the command line? This would be for a development build. I'd like to use a shell script of some sort and call it to retrieve this info. Is this possible? If so, how?
UPDATE:
I also need to get it from the unrooted device not simulator unfortunately. Its because I want to grab the APNS token and store it somewhere. I am storing the APNS token in a NSUserDefaults currently. To be clear, I have a iOS app, and I want to get the APNS token that I'm storing in NSUserDefaults using a command line script on Mac. The reason I need it from the device is I can't do push notification from simulator so I wont get APNS token unless real device registers.
update: i saw this SO article Browse the files created on a device by the IOS application I'm developing, on workstation? but i want to automate this. Anyway to pull down the container from shell using xcode command ?
If you're using the simulator you can find them in
~/Library/Developer/CoreSimulator/Devices/<dev-uuid>/data/Containers/Data/Application/<app-uuid>/Library/Preferences/<app-bundle>.plist
dev-uuid is the UUID of the simulator (you can find a list of them with xcrun simctl list)
app-uuid is the UUID for this installation of the app
app-bundle is your app bundle (i.e. com.test.testApp)
First of all, you do not need to solve this problem. Just write some code to print data to console.
If you do need to do so, here is the solution for standard user defaults (group user defaults is stored in another path, which I can not handle now).
Make sure your app is not installed via App Store.
Install iExplorer (on Mac OS or iFunbox on Windows) and plug in your device.
Open iExplorer (or iFunbox) and browser to this app. Export the whole sandbox directory to you PC.
The user defaults is stored in Library/Preferences/<app-bundle>.plist. Open it with Xcode.
Related
I want to save some data even after app uninstalls and installed again.
I don't want to use keychain because of some reason personally.
Or Is there any way to get unique key per device like UUID ? or per device per app ?(From ios 10 )
Could you help me, please?
You can save the details to a file and export that file using the Share extension in iOS application. Whenever the application is installed again then the app can import the data again from that file.
This is just a workaround but I strongly recommend Keychain in this case.
My understanding is that because of sandboxing, it isn't possible to view any text file (ie config file) associated with an iOS app using another app. Something quite simple with Android. Am I mistaken?
I am trying to implement a text config file with a Unity iOS app that gets loaded and parsed once when the application boots.
This config file would also be able to be edited and saved manually on that actual iOS device.
(addendum)
In Unity there is PersistentDataPath which resolves to /var/mobile/Container/Data/Application/foo/Documents
Is there an iOS supported file explorer app that will allow me view and edit files in this location (without jailbreaking)?
Use can check iOS App Groups. It allows multiple apps access to shared containers and allow interprocess communication. There is no so much documentation about this, but maybe that's what you're looking for. At least you can share NSUserDefaults between the apps.
NSUserDefaults it's a most simple way to save any (not big) configurations for your app. For manual editing: if your app on the device signed with developer certificate, you can connect through any iOS supported file explorer app and edit it. But after release, from App Store, your app installed in restricted/private path, so it's not possible, if only you don't have a jailbreak.
Initial configuration you can put into your app bundle, and at the first run just copy them to NSUserDefaults.
Short answer: There are utilities such as iExplorer - https://macroplant.com - that allow "file manager" type access. However...
Long answer: If your app requires users to buy (or get) other software to modify configuration files, the chances of Apple approving it are slim to none.
The appropriate thing to do is to provide a User Interface in your own app which allows the user to modify / update the settings.
This is my first iPhone app. I'm using Xcode 7.3.
In the app I used this tutorial to create an sql database using the app (when the user gives permission by pressing a button, it creates the .db file).
Now I would like to know how I can download the database from the app.
Here is why:
The app will be downloaded on someone's device (not via the app store). It is supposed to collect data from a wearable device and store it in the database.
However I don't know how to access that data later on when I have the user's phone. Apparently the db lives in
/var/mobile/Containers/Data/Application/###/Documents
I read that one method is "jailbreaking." But I have never done that and this is not my phone I'm dealing with, it's a client's, so I don't feel comfortable hacking it. Is there another way? Possibly through the terminal (this is how I did it with the android app, using adb)?
Or is there another way I can go about saving the database so that it is accessible/retrievable?
The first answer is correct but incomplete :
Once you have download the Container, the extension is .xcappdata, so you need to right-click on it and select show the package.
Then browse into /library/Application support/ to find your database in .sqlite
You can try to connect the device to your Mac, then in XCode, go to Window, Devices, select your device and app bundle and click "Download Container...".
To see the database, you could use SQLite.
I am developing an app for Jailbroken iOS devices that access Safari history. History.plist file is placed at following path.
/private/var/mobile/Library/Safari/History.plist
I have successfully installed my app on jailbroken iphone by following tutorial
Use your jailbroken iPhone in Xcode for developing
When I try to access above path using fopen command of C, I can not access it. My code is below
FILE *fp = fopen("/private/var/mobile/Library/Safari/History.plist","r"); // read mode
if( fp == NULL )
{
NSLog(#"This file does not exist");
}else{
NSLog(#"This file exists");
}
It returns NULL file pointer.
I have Googled this and got to know that since my app is still in sandbox so I am not able to access above path. Couple of posts including [Why SandBox in iOS 6.1.1 still exists for App even after I have jailbreak?][2]
[2]: Why SandBox in iOS 6.1.1 still exists for App even after I have jailbreak? and [how to get the message when receiving the “kCTMessageReceivedNotification” notification on IOS5][2]
[2]: how to get the message when receiving the "kCTMessageReceivedNotification" notification on IOS5 suggest that the app needs to move outside sandbox in order to access the complete file system.
I am confused about this. Can you please guide me how can I access this path?
Best Regards
Usually you will get a message in the console saying that access was denied. If the sandbox is indeed doesn't allow you to access browser history then you need to move your application outside of the sandbox. To do that you can copy your application into /Applications directory where all system apps are. You can do it using ssh, iExplorer or anything else that can access root folder of iOS device. Read this, the "The actual signing part" part. You can skip ldid stuff, you don't really need to sign anything unless you need to sign your app with entitlements.
I develop an iOS app and I send it to any beta tester. After 2 month app has a crash and now it doesn't work .
I need to get any information about log or better I need database. How can I get it ? I can connect to my Mac, but I don't know how to access to db data (if is it possible).
It's very important get database information.
Thank you.
In your device, you can access support directories only for applications compiled for development.
Connect your device to your computer. Having launched xcode, open 'Organizer' window (Window->Organizer). On the left hand side of the menu you will have your device displayed. Under your device, select 'Applications'. All the dev applications will be available there. Select the application you are interested in and click 'Download' at the bottom of the window. What happens - the support directories are downloaded. They are stored in bundle with extension '.xcappdata'. 'ctrl' click on the file and menu will give you an option 'Show Package Contents'. You will find there your sql database file.
You can either use XCode Organizer to download the application directory from the device, or if the tester is remote ask them to install a program like iExplore that lets you simply copy application directories off of the device to send to you.