Created
October 9, 2025 18:05
-
-
Save pixelmatrix/86f8816c68fa1435e1a0124af894e651 to your computer and use it in GitHub Desktop.
Revisions
-
pixelmatrix created this gist
Oct 9, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import SwiftUI extension ShaderLibrary { // Important: Cache this instance. Initializing it is expensive. static let library: ShaderLibrary = { // Make sure to use the right binary based on the target #if targetEnvironment(simulator) let filename = "Shaders-iphonesimulator" #else let filename = "Shaders-iphoneos" #endif // Bundle.module is for Swift packages. Use whatever bundle contains your shader files. guard let url = Bundle.module.url(forResource: filename, withExtension: "metallib") else { fatalError("Missing shader library") } return ShaderLibrary(url: url) }() } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # Compile for device xcrun -sdk iphoneos metal -o One.ir -c One.metal xcrun -sdk iphoneos metal -o Two.ir -c Two.metal xcrun -sdk iphoneos metallib -o Shaders-iphoneos.metallib One.ir Two.ir rm One.ir rm Two.ir # Compile for simulator xcrun -sdk iphonesimulator metal -o One.ir -c One.metal xcrun -sdk iphonesimulator metal -o Two.ir -c Two.metal xcrun -sdk iphonesimulator metallib -o Shaders-iphonesimulator.metallib One.ir Two.ir rm One.ir rm Two.ir # Include the .metallib files in your app / package's bundle