Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys :)
It’s been some years since I did any iOS software, but I remember I never saved a file
within the iOS Simulator in Xcode, even though I have an App that saves to Documents in the real iPhone.

Was this just because I never figured it out. or actually isn’t possible?
I don’t want to write any App now, but I do have my old software working,
and I’d like to do a program just to write a file, and get it out of the Simulator if possible.

I could use NSlog to copy it out of the debug window, but the file will contain data that is not just ASCII.
Cheers, Art.
 
All files that you created in Simulator are stored on Mac of course. Here you have example of path to the main directory of application
/Users/mkowalski/Library/Developer/CoreSimulator/Devices/314DCE38-1B48-4FD7-97B3-5816444C6FCA/data/Containers/Data/Application/45F309B1-E3DD-478B-AB57-B2C3B8C5AA81
 
Whenever starting a new app I add a few lines to the app delegate to print out the full path to the Documents folder and the app sandbox. It usually also prints a few other general bits of info like the OS version. It only prints in Debug builds. I leave that code in there permanently. Then if I later want to view a file that was written out I enter something in the Terminal like

Code:
open "/Users/mkowalski/Library/Developer/CoreSimulator/Devices/314DCE38-1B48-4FD7-97B3-5816444C6FCA/data/Containers/Data/Application/45F309B1-E3DD-478B-AB57-B2C3B8C5AA81"

and the folder opens in Finder.
 
Hello again, I have finally gotten to it.
Could you share how you get the path to NSlog please?

The program confirms that it wrote a directory, and a file of a specific name inside it,
but I still can’t find it.

EDIT.. can’t delete post.
Never mind, I thought printing the path would just be a Documents directory like an iphone would, but it does give the full path.
 
Last edited:
From the iOS Simulator, you can read or write anywhere in the macOS file system for which you have standard user access permissions. For instance: "/Users/myUserName/Documents/foo.txt" or "/tmp/datadump.bin"
[doublepost=1485315790][/doublepost]
The program confirms that it wrote a directory, and a file of a specific name inside it,
but I still can’t find it.

Give it a unique file name. Spotlight Search can then easily find it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.