johnbakers
johnbakers

Reputation: 24750

Is Xcode's "Target Membership" related to the Bundle?

I had previously thought that if you check the box for a file to add it to a target, then that is how it gets included in the application bundle. I have some audio files that I decided not to use and I unchecked them from the Target Membership. They are also not #include or #import anywhere. I "cleaned" the Xcode project using the Product menu and also deleted its derived data. As a test I did not remove lines like this:

NSURL* file_url = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:fileName ofType:fileSuffix]];
pcmData = MyGetOpenALAudioDataAll((CFURLRef)file_url, &data_size, &al_format, &sample_rate);

Where fileName and fileSuffix refer to these files that are no longer included in the target.

However, surprisingly, these files still load and play back fine.

So apparently, files get included in an application bundle in another way besides the "target membership" checkbox. How is this happening?

Upvotes: 3

Views: 2512

Answers (2)

Jonathan Grynspan
Jonathan Grynspan

Reputation: 43472

The target membership determines which target a file is processed for. For instance, if your project contains both a Mac target and an iOS target, and a source file is only included in the Mac target, it will not be compiled for iOS.

A file may be a member of multiple targets. A project may contain multiple targets and generally contains at least one. A target may establish other targets as dependencies (for instance, you can make a "compile resources" target and a "build open-source library" target dependencies of your main app target.)

It sounds like the file is still present in the app bundle that is already installed on the target device or the simulator. Files in your app bundle are not deleted when the app is updated. To delete them, you must uninstall and reinstall the app (or perform another operation that deletes the app data, such as wiping the phone or resetting the simulator.)

Upvotes: 5

Mick MacCallum
Mick MacCallum

Reputation: 130193

Removing items from your target will not remove them from existing builds (wouldn't that be nice). To solve this, you can remove the application from either your device or the simulator and when you build and run again, only the files added to your target will be copied.

Upvotes: 2

Related Questions