tags:

views:

38

answers:

4

If I include files in my Xcode project, how can I control or specify which files are included as a part of the application's bundle?

For example, all the PNG files I add to the project always wind up in the bundle. Conversely, the .m and .h files are not.

How can I control or specify which are or are not included?

If I through in something - like some random data file - how do I know if it gets built into the bundle or not?

+1  A: 

You control what gets copied where during a build by controlling what's listed in the various Copy Files phases of the build target.

Jeremy W. Sherman
+2  A: 

Right click on the file (either class file or resource file) which you don't want to include, select Get Info. Go to "Targets" tab. Check/Uncheck the box near the target name, for include/exclude the file.

Notes:

1) header files are by default excluded from the target. Only source files (.m or .mm or .cpp, etc) & resource files (.png, .jpg & all others) are required to be include/exclude from target.

2) If you exclude any source file from target then by default it's header file will get excluded & that source file won't compile.

3) Similarly, if you exclude resource file, it won't be copied into the bundle & thus any reference in your code to that file, will result into the crash of the application.

Sagar
+1  A: 

To control what is copied you can do the following:

  1. Click the image you're concerned with
  2. From the File menu select the Get Info option
  3. Select the Targets tab
  4. Select the targets you'd like to have the resource copied to, or deselect to not copy
Chris Gummer
A: 

In general, files (like .h & .m) are the exception. If Xcode doesn't know something special to do with them (e.g., compile), they're just included.

At some point, I thought Xcode would run a special rule on even PNGs (to optimize their size).

Jon-Eric