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
Related
I have a problem for saving pdf file on iPhone.
I have used the following objective c code to save pdf file:
NSURL *pathURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSString *filePath = [pathURL.path
stringByAppendingPathComponent:#"filname.pdf"];
[[NSFileManager defaultManager] createFileAtPath:filePath
contents:pdfdata
attributes:nil];
I can check whether the file is saved or not correctly using webview.
I can check the contents of the saved pdf file using webview.
But I can't find the saved file on both simulator and device.
Where can I find my saved file on iPhone?
If anyone knows the solution for my issue then please advise me.
Thanks.
Your .pdf file was saved in your application document folder. So, You can easily check on simulator. Like below
Print a downloaded file path
print(filePath)
then go to
Finder -> Go Menu -> Go to folder
and paste the filePath
This is the path of your application document folder
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.
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.
I am developing an iOS project. There, I am having to upload images to to PHP server. So I choose some images from gallery in simulator for check up. Selected image is stored inside simulator. But I couldn't find that folder. So image is going empty to server. How to find that folders?
That image stored path is below
User/Guest/Library/developer/core simulator/devices/1ABD8156-4A55-4189--BDCD-DA6F7CSB2229/data/containers/data/applications/1559E24-9738-447D-8888-EEC9E29D4D39/Documents/Photo.jpg
But here I can found until
User/Guest/Library/developer/core simulator/devices/1ABD8156-4A55-4189--BDCD-DA6F7CSB2229/data/containers/data/applications/
How can I solve this. Please help me.
Note: i am using xamarin studio for development.
This would get u the simulator directory.
[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
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.