views:

504

answers:

4

Hi there,

I have several resources in my iPhone app and when they get compiled they all get added to the root of the resources folder in the app regardless of the Xcode grouping structure. This is fine for most things, however there is a set of files that I need to have structured in folder in the app's resources folder.

At the moment, I have added my folders to Xcode using "Add Existing Files... -> Create Folder References for Added Folders". This is fine and the folder icons in Xcode are blue instead of yellow. My problem is that Xcode is not noticing and new or changed files within those folders and hence when I build my project, none of the new or changed images are in the target app's resources. The only way I can get it to work is to do a clean, and then build, which is quite annoying as I'm making changes and re-compiling maybe a few times a minute sometimes!

My folder structure in my resources that I want kept on in the app consists of several nested files and folder.

Is there some way to get Xcode to recognise all the files and folders that have changed or are new?

Thanks,

Mike

A: 

if you want to maintain a directory structure, it is best to do so in the documents directory. On your apps initial launch, copy over the files from the bundle to the documents directory in the hierarchy you prefer.

EDIT: after clarification, it seems that you probably just need to add some header search paths to your project. Open the targets info pane, go to the build section, and add your structures root folder to the header search paths list. Check recursive and you should be better

coneybeare
The problem is the folder's don't exist in the bundle without using folder references and building the project that way. And it's the building I'm having the problem with. Handling the folders in the bundle is fine. I just need Xcode to recognise any new files and folders in my project's files on every build so it compiles them into the target without having to do a clean and rebuild every time.
Michael Waterfall
i think you should play with the header search paths
coneybeare
Header search paths are for #include, not resources.
Kendall Helmstetter Gelner
A: 

I think that you need to "Add existing files..." every time that you add files, not only folders, in your project.

A solution could be to add a "Copy Files" step in your target build rules for copying resource files to your application bundle.

mouviciel
+2  A: 

i had your first problem myself today and i found this great article, which speaks about the second problem also: http://majicjungle.com/blog/?p=123

Cristi Băluță
Thanks for the great link. I've tried using the script but it doesn't seem to touch any files in sub folders. Any idea how to get it to touch files recursively in subfolders?
Michael Waterfall
+4  A: 

My problem is that Xcode is not noticing and new or changed files within those folders and hence when I build my project, none of the new or changed images are in the target app's resources.

This is a long-standing bug; it's bitten me many times while working on Adium. Please file it in RadarWeb. And thanks for the reminder; I've filed my own bug report as x-radar://problem/7232149 (visible to the public in OpenRadar). You should mention this bug number in your own bug report.

As a workaround, you can right-click on the folder reference and choose “Touch” to tell Xcode that the folder has changed.

Peter Hosey
Thanks for that info. I can't believe they haven't addressed it! I'm even finding that touching the folders doesn't seem to work, perhaps because there's some nesting involved.
Michael Waterfall