Access sqlite DB IOS - ios

I'm looking to access my sqlite database, be it via an application, browser or just the plain file. I can't find the file.
Not aiming for the dumbest question of the year award here, I seriously can't find it.
Supposedly it was in Library - Application support - Coresimulator - ....
Core simulator doesn't exist here, so I can't continue my search.
Then supposedly it was changed to Library - Developer - Coresimulator - Devices ....
Devices doesn't exist here, so I can't continue my search.
Allowing search for hidden files via command: defaults write com.apple.finder AplleShowAllFiles YES
Still not able to locate my sqlite database file. The application in which I'm using the database works like a charm, I just simply can't access the data that is stored because I can not find the file..
It probably is as stupid as can be, but please enlighten me as to where I can find it in my release of OS X. (10.10 yosemite)

Related

Transfer file from iOS app to computer while debugging

For a native iOS application we are integrating a C++ library which is writing some logs to disk to json file.
During debugging, we would like to access to this logs, but currently we can only do it by downloading the whole app container to the macOS machine and searching for the file there.
Since this a very time consuming operation we were hoping that there would be some solution that would allows us to get this file quickly. I did take a look to the lldb commands, but none of them seem to let you extract a file from the phone.
Is there anyway to do this in a quick way?
Thank you
Couple options...
1 - Add debug-only code in your app to share the log file (via AirDrop would probably be a good option).
or
2 - During debug, set these two keys (in project settings / info) to Yes:
Application supports iTunes file sharing
Supports opening documents in place
Once you've done that, you can open / copy files from your app's Documents directory (assuming that's where the logs are being written) from Finder on your Mac.

How to empty SQLite DB for iOS distribution/ Generic iOS build

I just submitted an app to the App store and it is now available. Unfortunately I realized that my development test data was included in the SQLite database! How do I go about emptying my database for the distribution, in other words removing all rows from tables? I know how to do this for a simulation (Reset content and settings), but since the deployed version just uses the Generic iOS build that does not run in the simulator, I am not sure how to clear the database.
Figured this out myself. You have to find the location of the sql file in your project.
Find the .sql file in your project.
Go to File-> Show in Finder
Then go to that location using Terminal and use sqlite3 to set up your DB as you want it.

Read and write files in development machine - ios

Is there a way to write in my local (not simulator) filesystem from an ios app developed with xcode, when I am running the app with Xcode's simulator ?
Reason: I have an ios application and I would like to have some content that the user could fetch as JSON data from my server. However, I would also like this JSON data to be generated from my (development) version, locally (so that I am sure it is exactly in the right format). I would therefore like my application to read and write in something like ~/User/myself/my_website/my_data/ rather than in the simulator's folder. Obviously this code would only be active in the development version and not in the release version (it doesn't need to be app review compatible).
Well, turns out it was trivial, and much simpler than writing on the device. Just specify a path to write to in the form of an absolute path and do [stringData writeToFile:path ...].

iOS 9 update seems to have broken sqlite3

After updating to the iOS 9.1 pre-release, our legacy iOS app that uses a local app sqlite database is no longer able to read tables ("no such table: xxx" errors). I have updated the sqlite3.dylib reference via Link Binary with Libraries (/usr/libs/...), and it seems to be able to connect and open the database just fine, but the "no such table" error still persists. One odd thing: when browsing to the database file on the file system during debugging, I am able to open up the database in Firefox SQLITE and see the tables in question, and confirm they exist.
One other point: the target architectures being built are arm7 and arm64 - $(ARCHS_STANDARD).
Thank you in advance for any tips / help!
Update: Even though the filepath to the database during debugging in the simulator exists and contains a valid database containing tables, trying to SELECT * from sqlite_master returns no rows -- leading me to think it is creating a new database, even though the file path it uses to open the database is valid and contains a database.
The problem ended up being related to event firing. It seems in iOS 8x, when the viewDidLoad, the filepath to the database was being set. Then the database was being opened and selected from without issue. In the exact same code in iOS 9 something was firing off before viewDidLoad which was opening the database with a nil filepath string. Not being a dedicated iOS developer, I am not 100% sure what the difference is in the two OS versions and delegate / event firing, but I thought I would answer my own post in case others had this problem!

iOS 6 local storage file appears twice

I have an app that uses local storage (using sencha 'Ext.data.proxy.LocalStorage') to view some content offline. I was rejected by itunes for violating the iOS Data Storage Guidelines.
I thought it might be related to the localStorage being inside the /Documents folder in iOS before iOS 5.1. To confirm that in newer versions the document folder is empty I checked, but I still found a .file__0.localstorage.
The strange think is that the same file (but without the leading dot) also exists in the library/caches folder, where it should be.
Both have the same content.
Does anyone know how this can happen? I already asked in the Sencha Support but it does not seem to be related to the Sencha framework.
Note: I am not using PhoneGap, only Sencha.
Making a very small Hello World Application with Sencha that writes to local storage I could reproduce this behavior. It seems like on application exit, it will write a copy of the localstorage file to the /Documents folder.
This seemed suspicious to me and it reminded me of the PhoneGap patch for iOS 5.1 that backs up the localStorage file also.
With iOS 5.1 Apple started to put the localStorage file in the Library/Caches folder which broke many applications because the data was no longer reliable stored. So PhoneGap and others started to implement Workarrounds that backup the localStorage file to the documents folder and automatically restore it if needed.
Trying to find proof that Sencha does something similar, I opened up the resulting .app package and found a stbuild_template file that contains the native wrapper code. It is of course compiled, but searching for the string "localStorage" results in some interesting results like:
restoreLocalStorage
preserveLocalStorage
Could not remove source file while backing up localstorage Could not copy localstorage backup . Caches WebKit/LocalStorage .file__0.localstorage file__0.localstorage
SNLocalStoreageFix
Also I found a lot of references to NimbleKit which seems to be used internally for the packaging.
This thread also hints at a solution for the iOS 5.1 local storage problem in Sencha Touch 2.1 which is what the OP is using: http://www.sencha.com/forum/showthread.php?194674-Localstorage-and-native-iOS-5.1-apps&s=04149e771f9c4eea15cb6f6d97069ff6
All this is evidence for me that Sencha implemented a workarround for iOS 5.1 which will put the localStorage in the /Documents folder. Since you only use the localStorage file for caching, Apple rejected you because you store non-user data in /Documents.
I think using PhoneGap there is an option to disable this backup. So you might want to consider using this or ask Sencha if they have a similar option to disable it.

Resources