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

2

6

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

Mishear answered 22/12, 2014 at 19:31 Comment(0)
E
7

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.

Elevate answered 22/12, 2014 at 19:56 Comment(3)
Okay - please elaborate on the "per-target groups". How to make them?Mishear
Just for your own convenience and to keep things with the same names separate, create Xcode groups that match the folders where you keep the target assets.Elevate
I finally got it working. 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 '')Mishear
B
-1

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.

Busywork answered 24/12, 2014 at 17:2 Comment(1)
Yes I am using source control, but it is not what I am looking for because it will end up with a lot of mergeing the could be solved easier..Mishear

© 2022 - 2024 — McMap. All rights reserved.