I try to develop something on Metal iOS and receive the following error:
Code:
let device = MTLCreateSystemDefaultDevice()!
Error:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
I'm on xcode 9.4.1
iOS SDK: 11.4
Architecture: arm64 armv7 armv7s
Can someone please help.
... SwiftUI calls this method before calling the makeUIView (context:) method. My Coordinator class is just a renderer of sorts, and during initialization requires an MTKView. This is where I am having trouble.
The answer is pretty much everything in MetalTexture! To switch texture loading to MetalKit, delete MetalTexture.swift from your project. Again, this will cause some errors; you’ll fix these shortly. Next, add a parameter to the initializer. Find this line of code:
When this tutorial series first started, there were issues in Swift that prevented you from using C data types like the ones found in the SIMD and GLKit frameworks. To overcome those issues, you ended up having to write an Objective-C wrapper to represent a 4×4 matrix and perform various GLKMath operations.
Apple presented MetalKit at WWDC 2015 as a gateway to Metal. The framework gives you utilities that reduce the amount of boilerplate code you have to write in order to get an app running on Metal. Texture loading: Allows you to easily load image assets into Metal textures using a MTKTextureLoader.
Test it on real device iPhone or iPad, it will not work on Simulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With