Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

targets

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 '')

like image 437
Morten Holmgaard Avatar asked Dec 22 '14 19:12

Morten Holmgaard


People also ask

What is difference between target and scheme in Xcode?

A Target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute.

What is aggregate Xcode?

Aggregated Targets is used when we need to build multiple targets together somehow. We will start by our example FruitBasket from the previous article and you can download it from this git repo, here is a preview of the code we have in there.


1 Answers

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.

like image 64
Phillip Mills Avatar answered Nov 04 '22 10:11

Phillip Mills