How can I control which files are included in the application bundle?
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 th开发者_Go百科rough in something - like some random data file - how do I know if it gets built into the bundle or not?
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.
You control what gets copied where during a build by controlling what's listed in the various Copy Files phases of the build target.
To control what is copied you can do the following:
- Click the image you're concerned with
- From the File menu select the Get Info option
- Select the Targets tab
- Select the targets you'd like to have the resource copied to, or deselect to not copy
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).
精彩评论