I did it like this with Xcode 12.0.1 and SPM 5.3:
Put my metal shader file inside directory: ProjectRootDirectory/Sources/TargetName/Metal/Shaders.metal
In Package.swift
.target(
name: "TargetName",
dependencies: [],
resources: [.process("Metal/Shaders.metal")]
)
3. Then I was able to load the library inside my package like this:
guard let library = try? device.makeDefaultLibrary(bundle: Bundle.module)
else { fatalError("Unable to create default library") }