Saving file in iPhone Simulator

Discussion in 'iOS Programming' started by xArtx, Nov 20, 2016.

  1. xArtx macrumors 6502a

    Mar 30, 2012
    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.
  2. imk_87 macrumors newbie


    Oct 27, 2016
    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
  3. xArtx thread starter macrumors 6502a

    Mar 30, 2012
    Thanks for the reply :) No wonder I never found them :D
  4. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    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

    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.
  5. xArtx, Jan 19, 2017
    Last edited: Jan 19, 2017

    xArtx thread starter macrumors 6502a

    Mar 30, 2012
    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.
  6. firewood macrumors 604

    Jul 29, 2003
    Silicon Valley
    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"
    --- Post Merged, Jan 24, 2017 ---
    Give it a unique file name. Spotlight Search can then easily find it.

Share This Page