views:

1022

answers:

3

I am developing an application which uses .js files stored in the Resources/javascript folder of my application bundle. In my Xcode 2.5 project I have created a folder reference (not a group) to my javascript folder, which automatically added the folder to the Copy Bundle Resources build phase.

The problem I have is when I modify my .js files, I need to clean my project then re-build it for the modified .js files to get copied into my application bundle when building. This is very time consuming since I re-build the whole project just to get an updated .js file in my app bundle.

Could someone tell me how to get Xcode to always copy specific files in the build phase?

Thanks in advance!

+1  A: 

Add a new Copy Files Build Task to your target.

Right Click (Control Click) on the target, Add -> New Build Phase -> New Copy Files Build Phase.

In the Dialog select the destination that you want the files to be copied.

This will create the phase under the target. Drag the files you wish to copy to the phase.

MarkPowell
This does the same thing as the Copy Bundle Resources build phase: it does not copy the files each time.
Form
I have recreated what you described, namely creating a link to a folder (outside the project) containing javascript files. I then added the Copy File Build Phase, selected Resources from the select box, added 'javascript' as the path, added all the javascript files to it and ran and build the app. All the files were copied into the bundle at Contents/Resources/javascript. I then made a minor change to one of the javascript files, build the app again, and the change showed up as expected. This was, however, in Debug build configuration. Perhaps you are using something else?
Elise van Looij
Nope, I am not using another build config. Note that I'm working in Xcode 2.5 on Tiger though as I stated in my question. Maybe it doesn't work that way in 2.5?
Form
Must be. 2.5, eh? Well, I'm sure there are good reasons for sticking to 2.5 ... no, there aren't. Save yourself, upgrade.
Elise van Looij
If Xcode behaves this way each time and is reproducible, I'd definitely call this a bug. http://bugreporter.apple.com
Joshua Nozzi
+1  A: 

You could right- or control-click the file (in the project file list) and click "Touch" before building (manual) or add a script build phase to the target that calls "touch myfile.js" and place it before your Copy Files build phase (automatic).

Joshua Nozzi
I tried that but the files weren't copied... maybe it only works with source code files?
Form
Almost seems like something else is going on. It's weird enough that modifying the file isn't enough to get it copied, but directly telling it to touch the file first, then going about the copy files build phase should definitely get it going if it's set up right. More detail would be helpful.
Joshua Nozzi
Maybe it has something to do with the folder reference? It's not actually a group in the Xcode sidebar. I can't think of anything different other than that...
Form
This seems to work sometimes... maybe Xcode has a bug.
Form
A: 

There's an excellent walkthrough here of a build phase script which automates the 'touch' and saves the manual step of specifying each file you want included.

bhowell