Reputation: 20569
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
Upvotes: 10
Views: 8057
Reputation: 31
I just got bitten by this bug too. The answers already given here were a great help.
I found the answer in this other thread useful too, but I'm not sure if it is actually a safe thing to do (it seems to generate a new AppId or something):
iphone simulator resources not updating
These are my personal notes I made to workaround it.
1) Open the project in Xcode
2) Right-click the folder reference (BLUE folder) in the navigator
at its root and pick "Remove Reference"
3) Close Xcode all the way
4a) Warning, this step might cause other problems in your project.
4b) Open the folder browser / Finder
4c) Navigate to: /users/USERNAME/Library/Application Support/
/iPhone Simulator/version/Applications/THISPROJFOLDER
4d) Delete this whole THISPROJFOLDER. The name of the folder may be all
numbers, but this clears the Xcode "Cache" so it will rebuild things
5) Find the actual folder where you store your pictures that were referenced,
and move the folder elsewhere and rename it.
6) Now open Xcode
7) In Xcode, select Product -> Clean. It should clean successfully.
8) Now run the program through Xcode. It should run, but (hopefully) crash or
otherwise fail because it doesn't detect the resource files you removed.
9) Now go standard Xcode usage and add the files back to the folder you want,
and add a reference to that folder in the Xcode navigator. Run the program
again, and it should detect the UPDATED PDFfiles/Imagefiles.
EDIT: Okay, I followed the "answer" instructions from Peter Hosey's post above, and that works too. Probably better than my solution here, because my step 4 (required) seems to regen an app key or something.
So here's how I fixed it in Xcode 4.0 following Peter's post:
1) Open your project in Xcode
2) Select the main project root item in the Navigator
3) Select "Build Phases" in the main pane
4) Select "Add Build Phase" button -> "Add Run Script"
5) Reposition he "Run Script" entry bar in the screen,
and move it to just-before the Copy Bundle Resources area
6) Edit the run-script you just added in the main pane:
: Set Shell to: /bin/sh (its the default, or try /bin/tsch)
: Set the script line to: touch -cm ${SRCROOT}/MyDocs
(Set it to your folder root area, matching the Blue Folder
area in your Navigator)
7) Save it all and select "Product -> Clean" to clean project
Upvotes: 3
Reputation: 96393
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.
Upvotes: 10
Reputation: 1305
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
Upvotes: 4
Reputation: 33101
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
Upvotes: -1