nodejs/node · error · ValueError

Found multiple build files for ${name}

Error message

Found multiple build files for ${name}

What it means

Raised by _AddBuildFileToDicts when a second, distinct PBXBuildFile object references the same underlying XCFileLikeElement (a PBXFileReference or PBXVariantGroup) already added to this build phase by a different PBXBuildFile. While the same path is caught earlier, this catches the case where two different PBXBuildFile wrappers point at the same file reference object.

Source

Thrown at tools/gyp/pylib/gyp/xcodeproj_file.py:1941

        elif isinstance(xcfilelikeelement, PBXVariantGroup):
            for variant in xcfilelikeelement._properties["children"]:
                paths.append(variant.FullPath())
        else:
            paths.append(xcfilelikeelement.FullPath())

        # Add the paths first, because if something's going to raise, the
        # messages provided by _AddPathToDict are more useful owing to its
        # having access to a real pathname and not just an object's Name().
        for a_path in paths:
            self._AddPathToDict(pbxbuildfile, a_path)

        # If another PBXBuildFile references this XCFileLikeElement, there's a
        # problem.
        if (
            xcfilelikeelement in self._files_by_xcfilelikeelement
            and self._files_by_xcfilelikeelement[xcfilelikeelement] != pbxbuildfile
        ):
            raise ValueError(
                "Found multiple build files for " + xcfilelikeelement.Name()
            )
        self._files_by_xcfilelikeelement[xcfilelikeelement] = pbxbuildfile

    def AppendBuildFile(self, pbxbuildfile, path=None):
        # Callers should use this instead of calling
        # AppendProperty('files', pbxbuildfile) directly because this function
        # maintains the object's dicts.  Better yet, callers can just call AddFile
        # with a pathname and not worry about building their own PBXBuildFile
        # objects.
        self.AppendProperty("files", pbxbuildfile)
        self._AddBuildFileToDicts(pbxbuildfile, path)

    def AddFile(self, path, settings=None):
        (file_group, hierarchical) = self.FileGroup(path)
        file_ref = file_group.AddOrGetFileByPath(path, hierarchical)

        if file_ref in self._files_by_xcfilelikeelement and isinstance(

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Ensure each XCFileLikeElement is wrapped by exactly one PBXBuildFile per build phase.
  2. If you are constructing PBXBuildFile objects manually, reuse the existing one instead of creating a new wrapper for the same file reference.
  3. Review the gyp target configuration that produced duplicate build-file wrappers; deduplicate the underlying source entry.
  4. File a gyp bug if the configuration is clean and this still triggers — it may be an internal generation logic error.

Example fix

# conceptual: when building xcodeproj objects
# before
bf1 = PBXBuildFile(fileref=ref)
bf2 = PBXBuildFile(fileref=ref)
phase.AppendBuildFile(bf1)
phase.AppendBuildFile(bf2)  # raises
# after
bf = PBXBuildFile(fileref=ref)
phase.AppendBuildFile(bf)  # add once
Defensive patterns

Strategy: validation

Validate before calling

# When constructing PBXBuildFile objects, ensure one wrapper per file reference per phase
if filelikeelement in phase._files_by_xcfilelikeelement:
    return phase._files_by_xcfilelikeelement[filelikeelement]  # reuse existing

Prevention

When it happens

Trigger: AppendBuildFile(pbxbuildfile) is called where pbxbuildfile wraps an XCFileLikeElement already present in self._files_by_xcfilelikeelement but mapped to a different PBXBuildFile object. The build phase rejects two separate build-file entries for the same underlying file reference.

Common situations: Programmatic .pbxproj construction (or a gyp code path) that creates two PBXBuildFile objects for the same file reference and adds both to the same phase. Internally indicates a logic error in how build files are constructed rather than a simple duplicate path.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/66611aad816b37cd. Report an issue: GitHub.