No metal texture found

With every metal-based ImageView implementation, I ran into the same problem

let targetTexture = currentDrawable?.texture else{ return } 

A value of type "MTL; DRawable" has no member texture

It seems like an apple has changed some kind of metal api

here is the full function I'm trying to use:

 func renderImage() { guard let image = image, let targetTexture = currentDrawable?.texture else{return} let commandBuffer = commandQueue.makeCommandBuffer() let bounds = CGRect(origin: CGPoint.zero, size: drawableSize) let originX = image.extent.origin.x let originY = image.extent.origin.y let scaleX = drawableSize.width / image.extent.width let scaleY = drawableSize.height / image.extent.height let scale = min(scaleX, scaleY) let scaledImage = image .applying(CGAffineTransform(translationX: -originX, y: -originY)) .applying(CGAffineTransform(scaleX: scale, y: scale)) ciContext.render(scaledImage, to: targetTexture, commandBuffer: commandBuffer, bounds: bounds, colorSpace: colorSpace) commandBuffer.present(currentDrawable!) commandBuffer.commit() } 
+5
source share
1 answer

I had the same problem after performing a system update and xcode. It turns out during the update process, xcode switches the build target to the simulator. As soon as I switched the target back to the device, everything was compiled again.

+8
source

Source: https://habr.com/ru/post/1263520/


All Articles