Read/Write To Package Contents?

Discussion in 'Mac Programming' started by Darkroom, Apr 15, 2009.

  1. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    is it not possible to read/write to "Package Contents" paths (or whatever they're called)? i'd like to write a program that writes a file to the applications resources folder. using XCode as an example:

    NSString *textFile = @"/Developer/Applications/Xcode/Contents/Resources/myTextFile.txt";
  2. larkost macrumors 6502a

    Oct 13, 2007
    It sounds like:
    [[NSBundle mainBundle] resourcePath]
    would get you what you want, but I am going to really, really recommend against doing this if you are going to write to that location. A much better target would be to write out to folders in ~/Library/Cache or ~/Library/Application Support. Or you could write out to the a folder in the users /var/folders folder (use confstr() with _CS_DARWIN_USER_TEMP_DIR, to get that). But I would caution against that last one, as it is not commonly known to users that that exists, and filling up their drive in a spot they are not likely to find is likely to make them angry.
  3. Catfish_Man macrumors 68030


    Sep 13, 2001
    Portland, OR
    Writing to the application bundle will break code signing, if you use it. It's generally not recommended.

Share This Page