You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?
Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, 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 a default.metallib file".
import Foundation
import Metal
letdevice=MTLCopyAllDevices().first!
letlibrary=try! device.makeDefaultLibrary(bundle:Bundle.module)
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 Package Manager - Swift 5.10.0-dev
Swift & OS version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Darwin Midnight-One.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: