Fix file elements being added to more than one group - #1652
Open
Ckitakishi wants to merge 3 commits into
Open
Ckitakishi wants to merge 3 commits into
Ckitakishi wants to merge 3 commits into
Conversation
The first two tests reproduce multiple parents: a source pointing at the spec directory, and a directory reached first through a file source. The third preserves a skipped subdirectory at the project root when a later source populates it. `expectSingleParents` lives in TestSupport so the fixtures are covered too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`getGroup` infers "top level" from the shape of the path, which stops holding once the same directory is also reached as a child. Drop anything that gets attached to a group from `rootGroups`, and rewrite its path, project relative until now, to be relative to the new parent. The TestProject fixture loses the duplicate `Folder` entry in the main group. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ckitakishi
added a commit
to Ckitakishi/XcodeGen
that referenced
this pull request
Sep 17, 2026
Ckitakishi
force-pushed
the
fix-multiple-parent-groups
branch
from
September 18, 2026 00:33
65dbfb7 to
e2025b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
XcodeGen could add the same file element to both the main group and another group, producing a malformed project that Xcode 27.2 refuses to open.
getGroupnow removes an element fromrootGroupsbefore attaching it to another group. A top-level group's path is relative to the project, so it is also rewritten relative to its new parent.This also resolves the malformed structure reported in #405.
Behavior change
Previously, specs whose source directory is the spec directory itself (
sources: [../Module]) showed their subdirectory groups at the project root. They now appear under the module group, one level deeper, which is the structure the spec describes. File references and build files are unchanged.The
TestProjectfixture changes for the same reason:Folder(type: folder,group: CustomGroup) was a member of bothCustomGroupand the main group, and now only lives inCustomGroup.Testing
Two regression cases in
SourceGeneratorTestsfail onmaster:A third case ensures that a skipped subdirectory populated by a later source remains reachable.
expectSingleParentsalso runs while generating the fixture projects, so the invariant is checked across all fixtures.swift testpasses.Fixes #1651.