Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

xcode resources simulator/iPhone problem

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)

Posted on Sep 9, 2008 4:28 PM

Reply
5 replies

Sep 11, 2008 3:29 PM in response to Lazrhog1

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.

Sep 12, 2008 8:52 AM in response to Lazrhog1

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"];

Sep 12, 2008 9:32 AM in response to jerbeers

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 🙂

xcode resources simulator/iPhone problem

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.