I am using FMDatabase in my project I need to check the data in the table. Is there any tool or anything else that will help me see the db entries which is on real device ?
If you want to check data from of your applications sqlite file check it on simulator version is easy. Where you initialise database, print documentDirectory path in your application:
// Get Document Directory path of the device.
- (NSString*) documentsDirectory{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [paths objectAtIndex:0];
}
Navigate to that path in Explorer by cmd+G and pasting the path in text box. You'll see one .sqlite file in that folder. Open it with any sqlite explorer, I use Mozilla AdOn or SQliteManager.
But if you wanna check db from your device:
Open device manager Xcode
Select your device
Click on installed app installed app in right pan
Select your app
Download it (see attached image)
And then explore the package to find sqlite file in it.
Related
Hello I have an app in my code that loads a file into a Bluetooth device, but it seems like if I change that file for the new version of the app it doesn't update it if I just reinstall it. I have to actually delete the app and install it again. Anyone know why? Is there some cache storing?
NSString *fileInDocuments = [documentsDirectory stringByAppendingPathComponent:#"samplefile_pack.bin"];
NSLog(#"File: %#", fileInDocuments);
if ([fileManager fileExistsAtPath:fileInDocuments ] == NO) {
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:#"samplefile_pack" ofType:#"bin"];
[fileManager copyItemAtPath:resourcePath toPath:fileInDocuments error:&error];
}
I'm assuming v1 of your app has the same code as the v2 of your app posted in your question. Assuming this is true, the behavior you see makes perfect sense.
A user runs v1 of your app. The file isn't in the Documents folder so it gets copied from the app bundle. Now, every time they run your app, the file exists and that copy in Documents is used.
Now the user updates to v2 of your app. The same check is made. The file already exists in Documents so nothing is copied.
Since your question implies that you want an updated copy of this file installed the 1st time v2 of the app is run, you need to detect whether the user currently has the file from v1 or v2 in the Documents folder.
There are a few ways to solve this. One option is to rename the file to something like samplefile_pack2.bin. Then your check can be for the new file name. You can also check for the old one and delete it if it makes sense.
I need to look my application's database file.I found this question:
How view data stored in Core Data?
In answer he said:
Your app will be folder inside (~ is your home directory):
~/Library/Application Support/iPhone Simulator/User/Applications/
I opened the Application Support folder but there is no iPhone Simulator folder inside this folder.
What should I do ? Here is the screenshot:
Edit:I am using xCode 6 and Yosemite.
The iPhone Simulator files have moved and can be a bit of a pain to find now. Each simulated device has a folder in ~/Library/Developer/CoreSimulator/Devices. You can root around in there until you find the simulator you're looking for. I wrote a tool to help locate the sandbox for each simulated device on which you've installed an app, but it's not perfect. You can find it here: https://github.com/somegeekintn/SimDirs
There is also an app called SimPholders2 that may be able to help you with this problem - http://simpholders.com/
for me it it is Library/Developer/CoreSimulator/Devices/C7E8D457-BFAB-43DA-8B0C-D9010BBB1D88/data/Containers/Data/Application/6B7DC6FA-2379-468C-A74B-60910A1CDCD1/Documents
device id and application id will be different for you though. this would give you documents directory for your app.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog (#"documentsDirectory %#",documentsDirectory);
OK The whole Problem lies in the fact that you need to open the Finder >> View >> Show View Options and then click to turn on Library.
Why would someone hide this so deep and obscurely?
You can use Core Data Lab to automatically find and view the database files of any Core Data app running in the simulator.
Info page: https://betamagic.nl/products/coredatalab.html
Free 14-trial: https://betamagic.nl/downloads/Core%20Data%20Lab%20Trial.zip
Diclaimer: I'm the creator of this tool.
As iam a newbie in iPhone app development, please help me with this issue.
According to my code, iam trying to create a folder called "New Folder" in the Documents. When i run this code, iam able to get the output in NSLog with the complete path and i can see where the folder is getting created in my system as well. But the problem is iam not able to see this folder in iPhone simulator. Is there any way to see this folder which i have created in simulator?
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(#"%d",[paths count]);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:#"%#/New Folder", documentsDirectory];
NSLog(#"Path is: %#",filePath);
NSFileManager *manager = [NSFileManager defaultManager];
NSLog(#"%d",[manager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil]);
NSLog(#"Folder created");
Yes you can see this folder by going through the following steps....
Open Your Finder Window. Go to Library -> Application Support -> iPhone Simulator -> Choose the type of Simulator(like 6.1, 5.0 etc) - > Applications -> Check the project of the simulator by its Name after going into the numbers -> Document.
This is your Document Directory. You will find your files here.
For more simplicity for viewing folders in document directory follow the steps:
1) NSLog the path and then copy it from console.
2) Open finder press Command+shift+g
3) Paste the path and press go.
You can see folder created manually by using following steps :
Go to Finder Window
Select Application Support
iPhone Simulator
Now, Select simulator version (say 6.1)
Applications (contains list of application that are executed)
Select your Application folder
Documents contains user created folders.
This is shown in screenshot
I am writing an IPhone application in witch I downloaded files and photos locally in the Supporting Files folder ( in the right panel of xcode ), these files are downloaded also in a web server, what I want is that if the application detect that these files are updated in the web server , it replace them with the new content in the Supporting Files I used
NSArray* pathArray = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask, YES);
documentsDirectory = [pathArray objectAtIndex:0];
NSString* localFile = [documentsDirectory stringByAppendingPathComponent:#"test.txt"];
[data writeToFile:localFile options:NSDataWritingAtomic error:&error];
the code works well but the problem is that it replaces content of files in
Library/Application Support folder and not the Supporting Files so when I do :
NSBundle *thisBundle = [NSBundle mainBundle];
NSString *TextURL = [thisBundle pathForResource:#"test" ofType:#"txt"];
NSURL *instructionsURL = [NSURL fileURLWithPath:TextURL];
NSString *TextString = [NSString stringWithContentsOfURL:instructionsURL];
mayText.text = TextString;
the old content is displayed and not the updated one
How can I change my code to replace files in Supporting files directory every time Application Support files are changed ? And what is the difference between these two folders? Thank you.
You can't. iOS Apps on the device are signed, changing the bundle's content would break that signing. And as all files that are managed by Xcode and added to a target go to the bundle, they must not be changed.
Instead download the files to a sandbox directory, such as Documents and access it there.
Also note that Supporting Files iin Xcode is not a directory but a group. It juste groups it content inside the Xcode project but does not organize the files in a directory on file system level.
I have created a database (IOS 5.1) with XCode 4.3.3 for the iPad and have set it up so that the user can backup and restore the database file (*.sqlite) to DropBox. Everything works fine...
Now I would like to do the same process but, set it up for iCloud. Looking for the following function:
Tap a button to backup the *.sqlite file from the Apps Document Directory up to iCloud at users preference.
Tap a button to copy the *.sqlite file down from iCloud to the Apps Document Directory.
I have been struggling trying to find the solution, any help will be greatly appreciated.
For moving any file to and from icloud you can use this code below.
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:your iCloudURL destinationURL:localDirectoryURL error:&errorsss];
only thing is if you are moving to icloud the code should be :
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:localDirectoryURL destinationURL:your_iCloudURL error:&errorsss];
and if you are getting it from iCloud to Apps Documents directory
[[[NSFileManager alloc]init] setUbiquitous:NO itemAtURL:your_iCloudURL destinationURL:localDirectoryURL error:&errorsss];