How to access Xcode database from iPhone app - ios

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.

Related

How can I see data inside an iOS app from Xcode?

An iOS app is supposed to remove all data when a user logs out of the app. This has been completed, but I am looking for a way to verify that there is no data left over in the app (SQLite, user preferences, etc.)
I cannot figure out how IO can link to the app from Xcode (or from somewhere else and "look" into the app after a user logs out and confirm that all data is gone.
Bryan
I cannot figure out how IO can link to the app from Xcode (or from somewhere else and "look" into the app after a user logs out and confirm that all data is gone.
You can download the directory that contains all the app's data:
Open the Devices and Simulators window in Xcode and connect to the device you want to examine.
You'll see a list of the apps that you've installed on the device. Find the one you're testing in the list and click on it.
Click the gear icon at the bottom of the list and choose Download Container....
Xcode will download a bundle named something like com.your.identifier 2018-12-17 14/18.28.448.xcappdata.
Find the downloaded bundle (you can choose where Xcode puts it) and control-click on it. Choose Show Package Contents. Finder will open a window showing you everything in the app's container.
In addition to just looking at the app container, you can also modify the container and install it on a device. This can be useful for testing. For example, you could modify or delete an important data file from the container and install it on a test device to test that your app gracefully handles an error situation. Or, if someone testing your app runs into a problem you can't reproduce, you can get a copy of the app container from them and install it on your own device.

transfer my own app from device to xcode

I have built an ios app which I have tested successfully on my ios device. Since last build Ive had to rebuild my laptop and as such Ive lost my xcode project. Is there a way I can transfer the app from my device back into xcode?
The way you are getting your thing is totally different. However you can recover some part of your project data like images, what framework you have used etc.
First you need to connect your device with your system, then open iTunes and select your app then download that app. Now you have to click on that app see option for Show In Finder and click it
If you see your .ipa file, then make it a zip of it and then unzipped it, a payload name folder will appear on your screen. you will see appName.app, right click on it and select show package contents. This will show the app package contents. You can recover few data from that. But if you are thinking to recover code level data then it is not possible.
And you need to make a backup of your project whenever you make any updations so that any accident happened does not affect your main project.
No that´s not possible to do... Next time use Source Control such as Git for example to keep track of your code and prevent this happening in the future (that´s one of many benefits of source control).

Get database from crashed iOS app

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.

how does iphone access sqlite database in my mac

I am crating an app in Xcode which stores some user information in an SQLITE database called contacts.db in my mac in the documents folder and my simulator is able to pull it up. So everytime a new user sings up, it has to update this DB.
If I publish this app and the app starts running in multiple iphones, will those iphones be able to access same database in my mac by default?
If not how will you make iphones access this contacts.db running in my mac? How do I create that link?
There are different tools for that one of this is iExplorer. You can Download and install it on your mac and access you app data. :)

Get data from user test on device to mac

I'm doing some user tests of my new iOS app and store some test data in a plist. When I do that in the simulator it is easy to get that file for further analysis on my mac, but how can I easily get it from a real device? This will only be used during testing and will not be part of the final version.
Possible ways I have read about but not tried (in hope to get some directions here first):
E-mail attachment
Enable file transfer to iTunes
Jailbreak (but don't want to)
Currently what I am doing is to NSLog it and copy and paste from Xcode into Excel, but this requires that the device is tethered to my mac.
Any experience or advice on easiest way to get this done?
I sometimes use iPhone Explorer to do this, because the plist file I want is not in my Documents folder. I use it to navigate to the files associated with my app on the device. Just connect your device to your laptop, run iPhone Explorer and then use it to locate the plist file you want and drag and drop it wherever you want.
You can save data from Organizer. Just click on your device and it'll show in right pane. Files from documents folder and possibly other folders can be saved.

Resources