yonaskolb / yonaskolb/XcodeGen

Having multiple targets share the same Source folder but excluding some files.

Open
#1,152 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
8.8k
Forks
908
Avg merge
17d 14h
Merged PRs (30d)
2

Description

As an example let's says that I have two targets A and B that share the same source files, with some minor exceptions.

I want to be able to exclude some files that would be only for A in my target B, and vice-versa.

Here is an example of my folder structure:

Root Folder
 |
 |-- Source
    |
    | - Screen1
       |
       | - View
           | - ViewState.swift // common file
           | - View_MMA.swift // file specific to A
           | - View_MMB.swift // file specific to B

In the XcodeGen settings file I define two targets, setting Source as the source folder and exclude settings for View_MMA.swift and View_MMB.swift:

targets:
  MMAPresentation:
    sources: 
      - Source
      - path: Source
        excludes:
          - "**/*_MM[!A].*"

  MMBPresentation:
    sources: 
      - Source
      - path: Source
        excludes:
          - "**/*_MM[!B].*"

I then run xcodegen and open the project.

All the files in the project explorer (expected) but when I check the target membership, View_MMA.swift and View_MMB.swift are members of both A and B while I would expect View_MMA.swift to be a member of A only and View_MMB.swift to be a member of B only.

  • I did check that my glob expression does match using globster.xyz
  • I did try to exclude one file with it's direct path in the exclude setting, but it was still a member of the targets

Would anyone know what am I doing wrong here?
Maybe the way I'm trying to use sources/excludes itself isn't right? In that case would there be any way to do what I'm trying to do with XcodeGen?

Thank you for your help

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue from the shown XcodeGen settings YAML with targets A and B, then inspect how each target's Source paths and excludes are handled when the project is generated. Compare the generated target membership for View_MMA.swift and View_MMB.swift; done means each file belongs only to its intended target while shared files remain in both.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.