Delete files from File System of IOS SIMULATOR - ios

How to delete images from image folder in library folder of an App created when accessing the app in simulator.The file has to be deleted through coding ie when the app has started running.
folder present in IOS simulator's file system?

The simulator installs apps are here.
/Users/<system username>/Library/Application Support/iPhone Simulator/User/Applications
GUID files and directories install on your simulator.
or you can uninstall app by Long Left button pressing and the cross.
Try this and let me know for any query.

The files that are saved in the library folder are present in the path
/Users/YourSystemName/Library/Application Support/iPhone Simulator/6.0 or 5.0 or etc/Applications
You can delete files of particular application from this folder.
But you can simply reset content and settings of iphone simulator to reset. This can done by
Selecting ios simulator.
Go to top menu and select iphone simulator.
Select option reset contents and settings and then reset.

Related

How do I access files in the iPhone Simulators "Files app"?

I saved a file on the iOS simulator to the Files App. Specifically, I chose to save into "On My iPhone" > Downloads.
Where can I find this file in Finder on macOS?
I found ~/Library/Developer/CoreSimulator/Devices/UUID/data/Downloads but that folder is empty even though when I launch the Files app in my simulator, I clearly see files in the Downloads directory.
I was able to find it by doing a search within the /UUID folder. Apparently files saved to the Downloads folder in the Files app are saved to:
~/Library/Developer/CoreSimulator/Devices/UUID/data/Containers/Shared/AppGroup/UUID/File Provider Storage/Downloads/

How to open database sqlite file on iPhone real device?

I'm debbuging a app in my real device by cable. I've a iPhone 6. I want check my database and operate with sqlite3 to query my results. The other questions and tutorials explain to do this only in simulator but I'm using a real iPhone.
In AppDelegate, I prints the path of database:
print(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last! as String)
/Users/myname/Library/Developer/CoreSimulator/Devices/DAE93E57-7004-45F6-9B93-E79CA1AEEEFA/data/Containers/Data/Application/D7A4F27E-6F11-4941-A1B0-0337ABF788AB/Documents
So, I take the path and access from terminal and access my database with sqlite3 DatabaseFile
But when I debugging in my device, the path that's printed not works. I tried use the printed path
cd /var/mobile/Containers/Data/Application/3257D423-C198-41A5-B29D-B31E99F84F34/Documents
/usr/bin/CD: line 4: cd: /var/mobile/Containers/Data/Application/3257D423-C198-41A5-B29D-B31E99F84F34/Documents: No such file or directory
This error happens because this is of iOS system, I think.
Xcode 10.1
In Xcode, go to Window > Devices and Simulators
In the Devices tab, select your application, then click on the Gear icon, then click Download Container...
Choose the location you want to save the file, then click on Save.
Go to Finder and find the .xcappdata file you just downloaded, then right click and select Show Package in Contents
The contents folder will open. Your .sql file is in AppData > Library > Application Support
I recommend downloading DB Browser for SQL File, and opening the .sql file with that. It works wonders!
In recent versions of Xcode (8 and up, I think), open this with Window menu --> Devices. Find the device in the device list and look at the installed apps list for the device. Each app that you've built and installed on the device will be listed (and maybe some others). Select your app and click the gear menu below the list. Clicking the "Download" item on the pop-up menu will enable you to copy the app's documents, library, and other directories to your Mac.
NB: This will download an .xcappdata file. Right-clicking on that and selecting "Show Package Contents" will allow you to drill down to the actual sqlite file.
Here's another way:
In debug mode, add a UIActivityViewController to share(copy) your SQLite database to a Mac or to a third party iOS app like SQLiteFlow(iOS), then you can debug your SQLite database.
Files that you've placed in the Documents directly should show up in File Sharing inside iTunes. You can download them locally and edit them there. You'll need to enable it in your app's Info.plist by adding:
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
The second key is actually only required if you want to enable showing these in the Files app.
You cannot access the .sqlite file in realtime when you debug your app using a device. Try accomplishing the same in the simulator and it will work.

Debugging Realm in iOS 8.3

I need to export .realm from Documents folder on real iOS device. Since iOS 8.3 Apple has disabled direct access to device's Documents folder how can I do that. For example I can send it by email, but is there any easier way?
You can download a device's container for your app from Xcode's "Devices" window with the following steps:
Connect your device to your Mac.
In the Devices window under Devices, select your device.
Under Installed Apps, select the app from the list.
From the Action menu (the gear icon), choose a menu item:
Show Container. A dialog shows the file contents of the container.
Download Container. In the dialog that appears, enter a location and click Save. The saved file will have a .xcappdata extension.
Replace Container. In the dialog that appears, select a file with a .xcappdata extension, and click Open.
Source: https://developer.apple.com/library/ios/recipes/xcode_help-devices_organizer/articles/manage_containers.html
You can still get to the Documents folder on a simulator. To find the folder of the simulator you're running on, first type the following in Terminal:
xcrun simctl list
And note the UUID of the simulator you're currently using.
Then navigate to ~/Library/Developer/CoreSimulator/Devices/<Simulator UUID>/data/Containers/Data/Application/<Application UUID>/Documents/.
You could also, in your app's code somewhere, get the path of your app's Document's folder and print it to the console with NSLog. Then copy the path, switch to Finder and press Shift-Cmd-G. Paste the path into the Finder field and it will take to your Documents folder.

Where is the (.app) project directory in iOS

I need to test my app with AppScanner for private API.
AppScanner said like following.
You can use App Scanner one of three ways: drop a compiled simulator .app folder into the GUI to scan the app, type method signatures into the search text field, or integrate the command line version into your build phase as part of a script to automatically check code right after it is compiled by Xcode.
I don't know where to find .app folder that compiled simulator.
Where is it?
The .app is in the Products Folder in your Xcode project.
As its Red now So you need to Build on a iOS device then it will be Black then Right Click and choose Show in Finder(it will open a finder window with .app location).
Here is path to iPhone Simulator path folder:
~/Library/Application Support/iPhone Simulator/[OS
version]/Applications/[appGUID]/
There you can find .app file.

can't find /var/mobile/applications directory for ios documents

I'm trying to run a release build on my iPad device connected to xcode for debugging. I'm not certain but guessing that when I do this the documents directory ends up somewhere on my local machine and not on the iPad (as when I run it without xcode). I get an output like this for the directory:
/var/mobile/Applications/FF0F1AB2-AD1F-4E42-8815-9E399EEF5027/Documents/
but I can't access that directory. Going to /var does not reveal any 'mobile' subdir. This seems different from when I run the iPad unconnected and end up with files viewable on the device through Organizer within xcode (making me conclude that it saves them locally in this mysterious dir when run connected to xcode).
Can someone help me access this mystery directory?
For "xcode 6":
Connect your device with your MAC (You can sure about that having a look into the simulator list, it should be there)
Now open xcode and go to "Windows" from upper menu
Go to "Devices" from drop down list
Now this window will pop up. Your app should be there in the "Installed Apps" section. Like the picture below. Double click on it.
Here you can see the "Documents" folder and the photos you saved earlier. You can't delete photo from this list. Because this is the iPhone device section, you accessing through the xcode.
If you want to delete the photos, you have to delete the whole project. To do that, scroll down below the screen and there should be a minus "-" button. After selecting your project just click on it. It will delete your photos as well as whole project.
Window -> Organizer -> select your's Iphone -> Applications -> select your iphone project name and you can see blow in the "Data files in Sandbox"
(Original poster here)
A few things I got wrong:
Running it on the device whether with the debugger or not always puts the file on the device, not on the local drive. This /var/mobile directory must be essentially some location on the device itself that can't normally be accessed browsing from the mac.
I needed to refresh the view in Organizer to see the files being placed there. I did so by detaching the iPad and then reattaching it (the usb), and the files would refresh.
Instead of removing the question, I'll leave this here for others and myself for the tip in viewing/refreshing files in organizer and the clarification of where the files are being placed when run on the device.
The directory you are looking for is located at
/Users/User Name/Library/Application Support/iPhone
Simulator/Simulator iOS Version/Applications/Application
ID/Documents/
Thank you they are both right in different contexts
If you are running it on device then what #ethemsulan is correct.
And then on the simulator the folder is found on your mac and the file path is as #Vin and #Osiris has given
Add this to your info.plist source code and you will find the recorded files inside files of iPhone device.
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
To see the file saved in iPhone -
Go to plist file of your project.
Set Supports Document Browser to "YES".
You will see the saved file in FILES in your device.
I am using iOS 13 and Xcode 11.6, it worked for me.

Resources