Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find the MyDocuments folder on iPhone Simulator?

I created a text file named Write.txt in the Documents folder in a Xamarin.iOS app. After that I was able to read its content to the console.

var documents = 
 Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filename = Path.Combine(documents, "Write.txt");

File.WriteAllText(filename, "Write this text into a file");
var text = File.ReadAllText(filename);

Console.WriteLine(text);  // prints out correctly

The problem is, that I can't found this file on the iPhone simulator's Files app. There is no Documents folder anywhere, and I don't get any results if I search for the filename.

(Yes, I'm new in iOS, so sorry if the question is stupid :) )

like image 544
kistelekig Avatar asked Oct 14 '19 16:10

kistelekig


People also ask

How do I find downloaded files in simulator?

You also may just go to the ~/Library/Developer/CoreSimulator/Devices/ folder in Finder ( Shift+Cmd+G ), and then click on the Date modified tab on the top of the folder menu. You'll get the most recently used simulator folder without UDID. After that, I navigate to data/Containers/Data/Application by hand.

How do I access iOS simulator files?

# Open application folder in Finder First, copy the path to the app folder from Xcode console. Then open Finder, click on Go -> Go to Folder and paste the application directory path. You will now be able to browse all the files in your application folder.

Where does the iPhone simulator store its data?

type: ~/Library/Application Support/iPhone Simulator. The Directories are the iOS version of the different Simulators. The Sub Directories are the Apps install on the simulator.


2 Answers

See Building Great Document-based Apps in iOS 11.

If you want to see it in the files app, you’ll want to set the following value in your Info.plist:

  • “Supports Document Browser” (UISupportsDocumentBrowser)

Or

  • “Application supports iTunes file sharing” (UIFileSharingEnabled); and
  • “Supports opening documents in place” (LSSupportsOpeningDocumentsInPlace)
like image 193
Rob Avatar answered Sep 18 '22 10:09

Rob


I just run your code and it all works well on my side. The file you written to was successfully opened. I guess you might have some wrong step when opening the folder, let me show you how to do it:

1.I run your code and then print the file path(the filename in your code), on my side it is:

/Users/myName/Library/Developer/CoreSimulator/Devices/0F06FD18-4307-4102-8A30-5EB017A4BD26/data/Containers/Data/Application/20A0294B-36C5-484F-8BD1-B69B977BA378/Documents/Write.txt

2.Go to your mac --> select Finder --> Then open the Go menu --> Click Go to Folder

screenShot

3.Paste your path to the text box:

enter image description here

4.Click Go and you will see the file:

enter image description here

Some folders are hidden in your system so you can't see them when search for the filename. Feel free to ask me if you have any question.

like image 30
nevermore Avatar answered Sep 20 '22 10:09

nevermore