IPhone SDK: How to have application files not be backed up by iTunes?

We are writing a set of files to the tmp directory on the device, with the expectation that iTunes will not back it up. However, we are seeing that those files are backed up on the host computer.
The following documentation:
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhone OSProgrammingGuide/ApplicationEnvironment/chapter6_section3.html
says:
"tmp/ — The application writes any other temporary files here. The application is responsible for cleaning up all files created in this directory; there is no automatic cleanup mechanism. Backup operations ignore the contents of this directory."
A sample value returned by NSTemporaryDirectory() is:
/private/var/mobile/Applications/65BED698-7789-41A0-A9BC-06BBDC5EB654/tmp
For which we are saving our files in:
/private/var/mobile/Applications/65BED698-7789-41A0-A9BC-06BBDC5EB654/tmp/NSData /080702c
However, when the device is disconnected and reconnected to the computer, and iTunes does a backup, we can see the files from tmp being transferred to a backup directory, eg.:
~/Library/Application Support/MobileSync/Backup/fb0a4b743a3c826d3146e0e34a9aa16e3c11eb0c
Our questions are:
1. Is the documentation correct about tmp not being backed up?
2. Are we getting the path to tmp correctly?
3. Is there something we can do or set to get tmp to not be backed up?
4. Is there another directory we should be using for data files which need to persist between application launches but not be backed up?
5. We have noticed that the path returned by NSTemporaryDirectory() is not the same as that formed by adding "tmp" to the path returned by NSHomeDirectory(); the former is /private/var/mobile/Applications/.../tmp while the latter is /var/mobile/Applications/.../tmp. Yet writing files to either seems to put them in the same place - are symbolic or other links being used to make these paths refer to the same directory? Which one should developers use?
Thanks in advance for any suggestions and help.

Partly to bump this but also to restate the question in less detail we a) want to save a number of text files for our app to use as a cache when it's relaunched, and b) don't want those files to be backed up by itunes when the iphone/touch is synced with the computer. How to do that?
We thought the "tmp" directory within our application's sandbox would be the place for that, however, itunes is backing up the files we put there.
Any ideas or suggestions much appreciated.
Thanks.

Similar Messages

  • IPhone SDK - How to add application files and folders to Xcode?

    I want to package a folder with data specific to my app. The data is just a bunch of binary files in proprietary format.
    These files should be installed under /Documents folder of the application. The files themselves will be in a folder called say Data. So when i run the app from Xcode i want it to copy the files to
    /Documents/Data folder under the bundlePath.
    There could be a file called data.dat under the Data folder.
    So in my application i want to be able to use the NSFileHandle interface or the standard C fopen() function to access the file /Documents/Data/data.dat .
    How can i do this using Xcode? Is there a tool one needs to use to create an install package?
    Any help would be greatly appreciated.
    -TRS

    If you look at the SQLiteBooks example, it shows and example of installing some extra data (books.sql) into the documents folder. Look at the function createEditableCopyOfDatabaseIfNeeded in AppDelegate.m
    You should also add in the starting/static data files in the build process in XCode - you can probably add to, or create another build step that will copy the files from your host machine into the app bundle.

  • After I've restored my IPhone 5, how do I get my downloaded music back onto my iTunes ?

    After Ive restored my Iphone 5 from recovery mode, how can I get the Music that Ive downloaded back onto my IPhone? Is there any possibilities that I can even do so? If so, How? Thanks.

    You can connect the phone to your computer and sync the tracks from your iTunes library. You can also re-download any purchases from Apple via the iTunes Store and the App Store by going to the "Purchased" tabs and downloaded your stuff.
    Perhaps you could try this to resolve your issue: http://support.apple.com/kb/HT4461

  • Hi, I have a new cell phone, I wanted to give my iphone to my father, instead of deleting the content on the iphone I have deleted the entire iphone. It starts up no more. iTunes will not recognize the iphone. How do I get my old data back onto the phone?

    Hi, I have a new cell phone, I wanted to give my iphone to my father, instead of deleting the content on the iphone I have deleted the entire iphone. It starts up no more. iTunes will not recognize the iphone. How do I get my old data back onto the phone?

    Place the device in DFU mode (google it) and restore as new.

  • How can I restore Camera Roll to my iphone 4s? I have Photo Stream and am backed up on iCloud

    How can I restore Camera Roll to my iphone 4s? I have Photo Stream and am backed up on iCloud

    Syncing notes with iCloud requires it have the correct email address linked, as notes get synced with an email address.
    Now, assuming that you have successfully set that up, though most people don't first time around, then if you deleted the note from the phone, it will have deleted from iCloud as well.
    Meaning, unless you have that note located in a backup in iTunes or iCloud you won't be able to get it back.
    You can restore the iTunes backup simply by connecting to itunes and hitting restore backup. Only thing is, any info that changed since the backup was made will be lost. (i.e. if your backup is a month old, your phone will look like it did a month ago, and only have that info on it.)
    Or, you can restore from iCloud, which requires erasing all content and settings, then selecting that backup. SO, you can see the predicament.

  • I have IPhone 5. Songs on phone do not match songs in my itunes library. Can't get rid of songs on phone because they don't show up in library

    I have IPhone 5. Songs on phone do not match songs in my itunes library. Can't get rid of songs on phone because they don't show up in library.

    Hi there,
    It sounds like you may need to hide these purchases in the iTunes Store in order to prevent them from displaying on the Apple TV. Take a look at the article below for more information.
    iTunes Store: Hiding and unhiding purchases
    http://support.apple.com/kb/ht4919
    -Griff W.

  • My husband and I share a new PC.  We have different music tastes and each have an iphone.  How can we both use our one computer and one itunes program with separate music libraries and separate iphones?

    My husband and I share a new PC.  We have different music tastes and each have an iphone.  How can we both use our one computer and one itunes program with separate music libraries and separate iphones?

    Each device only syncs waht you select.
    Select only what you want for each phone.

  • I have updated my iphone 4s with ios6 and now im not able to connect to itunes store. I can open the apps store but cannot install any app?  Anyone facing the same issue..

    I have updated my iphone 4s with ios6 and now im not able to connect to itunes store. I can open the apps store but cannot install any app?  Anyone facing the same issue..

    I have a 4S and upgraded to iOS 6 last week without any issues.
    Have you tried resetting your phone (hold the power and home buttons down together until the silver apple appears)?

  • HT4993 My iPhone 4s has tured off and will not turn back on I have only had it a week it has been in the Otter box case the entire time

    My iPhone 4s has tured off and will not turn back on I have only had it a week it has been in the Otter box case the entire time. What do I do to get my phone back on??????

    You can try to press the home button and power button and hold them for around 15-20 seconds. This will perform a soft reset similar to pulling the battery. If that doesn't help you may need to restore it.

  • How do i retrieve file not found music

    how do i retrieve file not found music

    According to your post, you're using Leopard, so FileVault only encrypts your user folder (unlike Lion). On the mounted external drive, in your user folder, you should see a file called username.sparsebundle, with username being your user name. Double-click that file to open it and it should prompt you for a password. Type in your password and the file will mount as a volume in Finder. You should be able to copy all of your files over.

  • My iphone 5 and 2 ipod touches will not show up on my itunes

    My iphone 5 and 2 ipod touches will not show up on my itunes when i connect them to my laptop.  I have tried different cables, restarted the mobile thing, uninstalled and reinstalled itunes, it is only on my laptop that has Windows 8. My dekstop with Windows 7 is fine will recognize them.  This has been going on for over a week.. What is going on?

    Hello Jennifer,
    The following article provides some useful troubleshooting that can help get your iPhone and iPods to reappear in iTunes.
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    Cheers,
    Allen

  • HT4061 my iPhone unexpectedly shut down and now is not turning back on, charging and is not being detected by my laptop, help

    my iPhone unexpectedly shut down and now is not turning back on, charging and is not being detected by my laptop, help

    i put that i held down the home button and all that... sorry, should of made my message a little clearer hun.. but i did try that, ive been searching video's on the net trying to figure out how to fix the problem, but nothing seems to be working... ive just tried pluging the usb lead into my phone while holding the home button then connecting it to my computer to see if itunes fires up, but even that didnt work... i dont know what else to try.

  • I recently had to install a new hard drive in my computer. This caused me to have to reload all content back to my iTunes and iPod. I have many apps on my iPod and i don't know how to transfer those back to my iTunes. Can anyone help?

    I recently had to install a new hard drive in my computer. This caused me to have to reload all content back to my iTunes and iPod. I have many apps on my iPod and i don't know how to transfer those back to my iTunes. Can anyone help?

    Right clicking on your ipod in the device list an d choosing "transfer purchases" will copy apps and bought media from iTunes to your computer. Due to the new iTunes library on your new HD, iTunes will erase your ipod during the first sync. To save your data to the computer take a look at this article about saving data from your device to a computer: http://support.apple.com/kb/HT4137
    Basically it's backing up manually, transferring her purchases (apps and bought music), letting iTunes erase the ipod due to the new iTunes library, and restoring from the manual backup again, to get all the data and settings back.
    Make sure your new computer account is authorized in iTunes. Disable autosync in itunes, connect your ipod, right click on it in the device list and choose backup.
    This will save data, pictures and settings to itunes. See what's included in this backup here: http://support.apple.com/kb/HT1766
    Transfer your purchases the same way to copy all apps and bought media from the Store to your computer.
    Set up at least one contact and event on your computer to be able the merge your calendars and contacts after your ipod got wiped during the first sync.
    The rest of the data can be restored from the backup you made.
    Restoring: http://support.apple.com/kb/HT1414
    Music is one way only, from the computer to your device, unless you bought the songs in itunes and transferred your purchases.
    There is 3rd party software out there, but not supported by Apple, see this thread: http://discussions.apple.com/thread.jspa?threadID=2013615&tstart=0

  • My iPhone 5 screen is black and will not come back on. The phone still works when paired with my vehicles Bluetooth what's wrong with it, and can I fix it?

    My iPhone 5 screen is black and will not come back on. The phone still works when paired with my vehicles Bluetooth what's wrong with it, and can I fix it?

    I have a similar problem.  I restored my iPhone 5 to the latest available OS.  After completing the process the phone never restarted.  The phone was fully charged when I restored it but now refuses to charge past the red battery icon.  I have been able to get the phone in UFD mode several times and have been able to load the new OS on the phone.  The Apple logo does come on and the software fully loads.  iTunes tells me the phone will restart but never does.  I left it to charge all night but it never appeared to load the battery.  This morning I went to the Grand Central Terminal apple store for help.  A woman at the store plugged the phone in but it never charged.  She absolutely refused to believe that I got my phone in UFD mode and loaded any software on.  I don't think it is a battery issue.  The only solution I was given was to buy a new phone.  Repairing it was out of the question.  At this point the phone is completely useless.  Thanks in advance for the help.

  • I dropped my iphone in water and the phone will not turn back on or charge...

    I dropped my iPhone in water and the phone will not turn back on or charge... I know its probably fried and I need it repaired but is there any possible way I would be able to save the information that was on it. Pictures or videos? Most of my pictures were saved on my i Cloud, but some information had not been uploaded like my videos.
    Does apple provide any sort of recovery services?
    Thanks
    Jesus

    Hi jesusdeloera, 
    Welcome to the Apple Support Communities!
    If your iPhone was being backed up to the iCloud or iTunes, you will be able to restore from that backup and recover the data that was on the device at the time of backup once you have your iPhone repaired. Please review the attached information about iCloud and iTunes backups. 
    Choosing an iOS backup method (Should I use iTunes or iCloud to back up my iOS device?)
    If you need further information about repairing your iPhone, please use the link below. 
    iPhone Repair and Service - Apple Support
    Have a great day, 
    Joe

Maybe you are looking for

  • Files moved to external hard drive - now nothing playing in iTunes...help!

    *Hi guys,* *Just wondering if someone can give me some advice really. I think / know I've made a bit of a botch up of my files :-(* *Here's the story - I'll try to be brief...I have done a number of different things to try and sort this mess out and

  • Creating a small "o" with a dash over it??

    I'm using IDCS2 on a PC and need to know how to create a small "o" with a horizontal dash over the "o". I'm doing a story for a product named Zon that has a dash over the "o" so it's pronounced Zone. I have a character reference chart for Windows usi

  • Indexing on attribute issue

    Hi: I have a container with large documents containing several documents with the following elements: <g:Value concept="J_DEBTOR" value="AL"/> I have an xquey with the following where clause: where ($series/generic:SeriesKey/generic:Value[@concept=xs

  • TextField bounds not working?

    I'm trying to make a simple GUI, it's just in the opening stages here, but my problem is that when the program is run, and the window opens up, the textfield (keyTxt) is the full size of the window... and when I don't add keyTxt, the label's bounds a

  • Kernel panic crash report, please help

    My macbook pro has been crashing regularly for a few weeks now - screen turns dark and gives the message telling me to shut down computer by holding down power button, etc.. Crash report is below. MacbookPro 2.4 Ghz Intel Core 2 Duo Memory 4 GB 1067