2

I'm trying to make a cocoa touch framework that will be performing some parallel computations on OSX/iOS and I'm having some issues with setting up the tests. Whenever I try to run :

library = device.newDefaultLibrary()!

I get hit by the error :

/Library/Caches/com.apple.xbs/Sources/Metal/Metal-55.2.8/Framework/MTLLibrary.mm:1016: failed assertion `filepath must not be nil.'

I was also trying to load shaders straight from the bundle without success.

How do I load up metal shaders properly so I can use them within a framework / tests?

Thanks!

2
  • Are you loading the shaders from the correct bundle for the tests? NSBundle.mainBundle() will not return a correct bundle for tests. Commented Mar 20, 2016 at 20:09
  • 1
    If you are trying to do this in a playground, the newDefaultLibrary() method will not work. you will need to create your own filepath like I explained in my blog post not long ago. Commented Mar 20, 2016 at 22:22

1 Answer 1

1

You can load a Metal library from your framework with this code:

let library = try! sceneKitView.device!.newLibraryWithFile(NSBundle(forClass: TheNameOfThisClass.self).URLForResource("default", withExtension: "metallib")!.path!)

BUT I filed rdar://22618641 in September 2015 with a sample project that demonstrates that you can’t load precompiled Metal libraries from frameworks — you get the same error you saw above when you try to use the library.

(Well, you CAN load the library, you just can’t actually use it.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.