Hive Hive
Sign in

Tuist Metal SPM Bug

GitHub issue · Open

Metadata
Source
tuist/tuist #9111
Updated
Jun 11, 2026
Domains
Generated projects
Details

What happened?

When using Tuist 4.78.1 with an external dependency containing Metal shader files, the build fails with duplicate file errors. The issue is that Tuist incorrectly adds the .metal file as a compiled source in addition to the resource bundle, causing duplicated symbol/file conflicts.

How do we reproduce it?

Follow the reproduce steps in this repo - https://github.com/danibachar/tuist-metal-spm-bug?tab=readme-ov-file#reproduction-steps

Error log

Prepare build
error: Unexpected duplicate tasks
note: Target 'MetalSPM_MetalSPM' (project 'MetalSPM') has compile command with input '/Users/danielbac/Documents/tuist-metal-spm-bug/MetalSPM/Sources/MetalSPM/Shaders.metal'
note: Target 'MetalSPM_MetalSPM' (project 'MetalSPM') has compile command with input '/Users/danielbac/Documents/tuist-metal-spm-bug/MetalSPM/Sources/MetalSPM/Shaders.metal'
error: Unexpected duplicate tasks
note: Target 'MetalSPM_MetalSPM' (project 'MetalSPM'): MetalLink /Users/danielbac/Library/Developer/Xcode/DerivedData/TuistMetalSPMBug-etciimxwzhwchpawforxshhjirgc/Build/Products/Debug-iphonesimulator/MetalSPM_MetalSPM.bundle/default.metallib
note: Target 'MetalSPM_MetalSPM' (project 'MetalSPM'): MetalLink /Users/danielbac/Library/Developer/Xcode/DerivedData/TuistMetalSPMBug-etciimxwzhwchpawforxshhjirgc/Build/Products/Debug-iphonesimulator/MetalSPM_MetalSPM.bundle/default.metallib
Unexpected duplicate tasks
Unexpected duplicate tasks

macOS version

15+ (Thao as well)

Tuist version

4.78.1 onward (this happens in all version after 4.78.1)

Xcode version

26.0.1, 15.x

Flights

Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.

New Flights are paused Configure model inference, GitHub, and a sandbox provider to start another Flight. Existing results remain available below.
No Flights yet

Start a Flight and preserve its objective, outcome, and session here.

Comments
L
linear[bot] Jan 13, 2026
D
dosubot[bot] Jan 13, 2026

This is a known regression in Tuist 4.78.1+ caused by changes in PR #8207, which altered how Metal shader files (.metal) are handled in SPM dependencies. The bug occurs because Tuist now adds .metal files as both compiled sources and resources, leading to duplicate build tasks and errors during compilation. This stems from how ProjectFileElements.swift and ResourcesProjectMapper.swift collect files for targets, without filtering out .metal files that are already specified as resources, resulting in them being included twice in the build process PR #8207, ProjectFileElements.swift analysis.

There are open issues tracking this problem: #8219 and #8299. The main workarounds are to either revert to Tuist 4.78.0, use pure SPM integration, or switch your package product type to .framework (instead of .staticFramework), which prevents Tuist from generating the problematic resource bundle target community workaround. Another option is to use a normal framework with MACH_O_TYPE=staticlib and implement a custom BundleFinder to access resources, which avoids the resource bundle duplication issue discussion.

If you need Metal build settings (like MTL_ENABLE_DEBUG_INFO) to be respected, you must set them directly on the generated bundle target, as Tuist does not propagate these settings automatically issue #8299.

There is ongoing discussion about improving resource bundle handling for static frameworks, but for now, the above workarounds are the most reliable solutions.

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about tuist with Dosu Add Dosu to your team

M
mamouneyya Feb 21, 2026

Have you found any workarounds? This is impacting my project too.

M
mamouneyya Feb 21, 2026

If you came here because of this issue too, then my workaround was to move the shader files outside of the Sources/{Target} and reference the folder explicitly in the Package.swift like this:

.target(
name: "Foo",
dependencies: [...],
resources: [.process("../../Resources/Shaders")] // <-- referencing it from outside the source folder
),

This will exclude it from being added to the compiled sources, but will keep in the resource bundle.

H
hanrw Mar 16, 2026

https://github.com/tddworks/ClaudeBar/actions/runs/23111613083/job/67129933992

ExecuteExternalTool /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -arch arm64 -isysroot /Applications/Xcode_26.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk -x c -c /dev/null
ExecuteExternalTool /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version
ExecuteExternalTool /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -isysroot /Applications/Xcode_26.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk -x c -c /dev/null
ExecuteExternalTool /Applications/Xcode_26.2.app/Contents/Developer/usr/bin/actool --version --output-format xml1
ExecuteExternalTool /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -V
ExecuteExternalTool /Applications/Xcode_26.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -version_details
Build description signature: 1e3ddec0c7e309fecdb9320bca2b537e
Build description path: /Users/runner/Library/Developer/Xcode/DerivedData/ClaudeBar-eisnjhvegwcegxbvwupeptxpuqbz/Build/Intermediates.noindex/XCBuildData/1e3ddec0c7e309fecdb9320bca2b537e.xcbuilddata
error: Unexpected duplicate tasks
note: Target 'SwiftTerm_SwiftTerm' (project 'SwiftTerm'): MetalLink /Users/runner/Library/Developer/Xcode/DerivedData/ClaudeBar-eisnjhvegwcegxbvwupeptxpuqbz/Build/Products/Debug/SwiftTerm_SwiftTerm.bundle/Contents/Resources/default.metallib
note: Target 'SwiftTerm_SwiftTerm' (project 'SwiftTerm'): MetalLink /Users/runner/Library/Developer/Xcode/DerivedData/ClaudeBar-eisnjhvegwcegxbvwupeptxpuqbz/Build/Products/Debug/SwiftTerm_SwiftTerm.bundle/Contents/Resources/default.metallib
error: Unexpected duplicate tasks
Testing failed:
note: Target 'SwiftTerm_SwiftTerm' (project 'SwiftTerm') has compile command with input '/Users/runner/work/ClaudeBar/ClaudeBar/Tuist/.build/checkouts/SwiftTerm/Sources/SwiftTerm/Apple/Metal/Shaders.metal'
Unexpected duplicate tasks
note: Target 'SwiftTerm_SwiftTerm' (project 'SwiftTerm') has compile command with input '/Users/runner/work/ClaudeBar/ClaudeBar/Tuist/.build/checkouts/SwiftTerm/Sources/SwiftTerm/Apple/Metal/Shaders.metal'
Testing cancelled because the build failed.
Test session results, code coverage, and logs:
** TEST FAILED **
/Users/runner/work/ClaudeBar/ClaudeBar/TestResults.xcresult

same