views:

155

answers:

1

When I start an Xcode project I drag in a blank readme.txt file that I use to take notes with while I'm figuring things out. The thing is, the file gets put in the app bundle at build time. Then I have to deselect it in the Detail view so that won't happen.

Is there a way to automatically exclude a file with a known name from every build?

I know Xcode is automatable, but I don't know where to look.

Using the latest non-beta Xcode version.

A: 

In the project outline view (by default this is the left hand pane when you open Xcode) locate your application under the 'Targets' section. Expand the subheadings, one of which will be 'Copy bundle resources'. You will probably find your unwanted text file has been placed here automatically. Highlight the file here and delete it - this will leave the file in your project but will prevent Xcode from copying it to your App bundle when you perform a build. To finish off, select 'Clean & Build' from the Xcode build menu to clear out your old bundle completely and recreate it with your new setting.

mikecsh
How is that, in any way, automatic?
willc2
What do you mean by 'automatic' here? This answer details an intitial setup procedure after which the file will 'automatically' be excluded from every future build without any user intervention.
mikecsh
If you want to add files but not have to perform this step, deselect all the checkboxes next to your targets in the 'Add to Targets' section of the Xcode add files sheet when you initially add the file(s).
mikecsh
I'm asking how to do this small step so I can begin to learn more advanced automation later. Do you know where I would start?
willc2
I see what you mean about deselecting 'Add to targets'. Neat. Ideally I would like to automate the whole 'adding of a file' process for multiple files with some being added to target and some not. Any ideas?
willc2
This may be possible by adding a 'Run script' build phase to your target as the first build phase but I'm afraid I don't know enough about the scriptability of Xcode to help you further.
mikecsh
I would love to know how to NOT include files that contain certain words - for instance: Files like "IMG-categoryname-desc.png" ... i would like to disallow certain categorynames from being included in certain target builds (automatically).
Jann