{"record":{"id":"66611aad816b37cd","repo":"nodejs/node","slug":"found-multiple-build-files-for-name","errorCode":null,"errorMessage":"Found multiple build files for ${name}","messagePattern":"Found multiple build files for (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/xcodeproj_file.py","lineNumber":1941,"sourceCode":"        elif isinstance(xcfilelikeelement, PBXVariantGroup):\n            for variant in xcfilelikeelement._properties[\"children\"]:\n                paths.append(variant.FullPath())\n        else:\n            paths.append(xcfilelikeelement.FullPath())\n\n        # Add the paths first, because if something's going to raise, the\n        # messages provided by _AddPathToDict are more useful owing to its\n        # having access to a real pathname and not just an object's Name().\n        for a_path in paths:\n            self._AddPathToDict(pbxbuildfile, a_path)\n\n        # If another PBXBuildFile references this XCFileLikeElement, there's a\n        # problem.\n        if (\n            xcfilelikeelement in self._files_by_xcfilelikeelement\n            and self._files_by_xcfilelikeelement[xcfilelikeelement] != pbxbuildfile\n        ):\n            raise ValueError(\n                \"Found multiple build files for \" + xcfilelikeelement.Name()\n            )\n        self._files_by_xcfilelikeelement[xcfilelikeelement] = pbxbuildfile\n\n    def AppendBuildFile(self, pbxbuildfile, path=None):\n        # Callers should use this instead of calling\n        # AppendProperty('files', pbxbuildfile) directly because this function\n        # maintains the object's dicts.  Better yet, callers can just call AddFile\n        # with a pathname and not worry about building their own PBXBuildFile\n        # objects.\n        self.AppendProperty(\"files\", pbxbuildfile)\n        self._AddBuildFileToDicts(pbxbuildfile, path)\n\n    def AddFile(self, path, settings=None):\n        (file_group, hierarchical) = self.FileGroup(path)\n        file_ref = file_group.AddOrGetFileByPath(path, hierarchical)\n\n        if file_ref in self._files_by_xcfilelikeelement and isinstance(","sourceCodeStart":1923,"sourceCodeEnd":1959,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/xcodeproj_file.py#L1923-L1959","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure each XCFileLikeElement is wrapped by exactly one PBXBuildFile per build phase.","If you are constructing PBXBuildFile objects manually, reuse the existing one instead of creating a new wrapper for the same file reference.","Review the gyp target configuration that produced duplicate build-file wrappers; deduplicate the underlying source entry.","File a gyp bug if the configuration is clean and this still triggers — it may be an internal generation logic error."],"exampleFix":"# conceptual: when building xcodeproj objects\n# before\nbf1 = PBXBuildFile(fileref=ref)\nbf2 = PBXBuildFile(fileref=ref)\nphase.AppendBuildFile(bf1)\nphase.AppendBuildFile(bf2)  # raises\n# after\nbf = PBXBuildFile(fileref=ref)\nphase.AppendBuildFile(bf)  # add once","handlingStrategy":"validation","validationCode":"# When constructing PBXBuildFile objects, ensure one wrapper per file reference per phase\nif filelikeelement in phase._files_by_xcfilelikeelement:\n    return phase._files_by_xcfilelikeelement[filelikeelement]  # reuse existing","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reuse existing PBXBuildFile objects for the same file reference within a phase.","If using gyp (not manual construction), deduplicate the underlying config to avoid this internal error."],"tags":["xcode","gyp","xcodeproj","build-phase","duplicate"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}