Open rgov opened 4 days ago
The default.metallib
is produced only if I use Xcode to build the package, but not SwiftPM from the command line.
It's unclear to me as a novice user why these should behave differently, and what the full matrix of supported features between a "pure" SwiftPM project vs an Xcode project is.
Is it reproducible with SwiftPM command-line tools:
swift build
,swift test
,swift package
etc?swift build
,swift test
,swift package
etc.Description
5822 discusses that "[r]esources of known types are automatically handled, as per the resources proposal", such that "all
.metal
files in a package are compiled into adefault.metallib
file".There's also a Apple Developer Forums post from 2020 that claims this behavior exists.
However, I do not see this occurring with my project. (Admittedly, this is my first time using SwiftPM.)
Expected behavior
The
add.metal
file is processed anddefault.metallib
is produced, such that it can be loaded byMTLDevice.makeDefaultLibrary(bundle:)
.Actual behavior
Library loading fails because
default.metallib
does not exist.The
add.metal
file is simply copied to.build/arm64-apple-macosx/debug/example_tool.bundle/add.metal
.Steps to reproduce
Here's
Package.swift
:And
Sources/main.swift
could look something like:The command
swift run
should succeed.Note
I am not able to locate any documentation about what process rules exist, and whether the behavior of compiling Metal is actually an officially-supported feature.
Swift Package Manager version/commit hash
Swift & OS version