5 Replies Latest reply: Sep 12, 2008 10:25 AM by jerbeers
Lazrhog1 Level 1 Level 1 (0 points)
Hi, I have searched and some people have had this issue but there has been no resolution yet. I have a directory of resources for my iPhone app. This directory contains some files and other directories.

I have added this as a resource to my xcode project, but it doesn't (appear) to get uploaded into either the simulator or iphone. If I copy the resources into the simulator directory manually (either application root, or documents) and then alter the code to look there for it, it finds it and runs perfectly. If I leave the copying to xcode, it doesn't happen and the app doesn't work.

I have tried both ways of adding the directory (yellow and blue folders) but to no avail. It is really bugging me now that this is the only thing stopping my apps.

Has anyone figured out why xcode doesn't copy the resources. Or if it is, where it thinks it is putting them ? I tried adding a new build copy phase, but that didn't seem to do anything either.

I really am exasperated by this...... sorry

Mac OS X (10.5.3)
  • 1. Re: xcode resources simulator/iPhone problem
    g.difalco Level 1 Level 1 (75 points)
    I never tried with a "folder" resource but all other files work well. I used the two normal methods:

    1) put the files in the project directory then "add existing file" in the resource folder

    2) do not move the files to the project, select "add existing files" and switch on the "copy files to destination folders (if needed)" checkbox in the window that's popping up.

    Both cases are ok in my Xcode; if you do the second action without checking the flag on, the files are not moved when building to a device or simulator.
    You can also check the resource list in the your-project.xcodeproj package (file project.pbxproj in it).
    No other ideas.
  • 2. Re: xcode resources simulator/iPhone problem
    jerbeers Level 2 Level 2 (300 points)
    I'm just guessing, but I think you might be getting confused because it includes resources in the application bundle. If you look at the app file in the simulator directory, you can see these files by right-clicking and choosing "Show package contents". You can access these files in code by using


    NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"resource.gif"];
  • 3. Re: xcode resources simulator/iPhone problem
    Lazrhog1 Level 1 Level 1 (0 points)
    awesome. It all became clear after looking in the package contents. So I wanted to add my resource directory with folder references (it turned blue) and then accessed as you showed above but by referencing my resource directory with

    NSString *rPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"data"];

    .. where data was the directory of resources that I added.

    thanks very much. That helped a lot
  • 4. Re: xcode resources simulator/iPhone problem
    Lazrhog1 Level 1 Level 1 (0 points)
    grrr, sorry that line didnt paste right

    NSString *rPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"data"];
  • 5. Re: xcode resources simulator/iPhone problem
    jerbeers Level 2 Level 2 (300 points)
    use


    ...


    to properly format the code you paste