Morten Holmgaard
Morten Holmgaard

Reputation: 7796

Xcode project with different versions of a file for each target?

I know that it is possible to add files to only some targets: Adding files to separate targets in Xcode 4

But is it possible to have multiple different version of a file (same name and path) included in an Xcode project - one for each target?

E.g. I have some images that are different from the target, but it is annoying that I have to replace the files each time I want to build another target.

How to solve this? In Android with Gradle you have different folders included after each target, but I haven't been able to find something similar.

Solved by answer but please note this comment:
Important lesson learn: Do not have a reference folder with same name as Target!!! You will get strange compile error that seems to have no relation to the problem. (e.g. unable to open executable '')

Upvotes: 6

Views: 4179

Answers (2)

Ali Beadle
Ali Beadle

Reputation: 4516

Is what you are after possibly provided by source control? Xcode supports Git which will allow you to branch to create multiple versions of your app, each with their own versions of files, switch between them as you need to and merge them back together when you want.

If you have never used it before it takes a bit of getting used to but makes supporting multiple versions so much easier as well as generally being useful for rolling back changes and comparing different versions. I found Ray Wenderlich's How To... guide very useful.

Upvotes: -1

Phillip Mills
Phillip Mills

Reputation: 31016

It works pretty much as you describe. You can create folders where you organize the files that are specific to targets and then make them part of the target or not by whether they're in a build phase for that target.

You really can't have two different files with exactly the "same name and path". Same name and parallel path, though, is fine.

Inside Xcode, you can make it obvious what's happening by having per-target groups that match the separated folders.

Upvotes: 7

Related Questions