The filter 'CIPortraitEffectSpillCorrection' is not implemented in the bundle

Hi, I use this function to generate a QRCode Image

Code Block
func generateQRCode(string: String, height: CGFloat, width: CGFloat)->UIImage?{
  let data = string.data(using: String.Encoding.ascii)
   
  if let filter = CIFilter(name: "CIQRCodeGenerator") {
    filter.setValue(data, forKey: "inputMessage")
    filter.setValue("Q", forKey: "inputCorrectionLevel")
    let transform = CGAffineTransform(scaleX: 3, y: 3)
     
    if let output = filter.outputImage?.transformed(by: transform) {
      let scaleX = width / output.extent.size.width
      let scaleY = height / output.extent.size.height
       
      let transformedImage = output.transformed(by: CGAffineTransform(scaleX: scaleX, y: scaleY))
       
      return UIImage(ciImage: transformedImage)
    }
  }
  return UIImage()
}


In another app works correctly but in the app that I develop I get this error.


The filter 'CIPortraitEffectSpillCorrection' is not implemented in the bundle at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/CoreImage/PortraitFilters.cifilter

How can I solve this?
Tillmoss, did you ever get a reply to this question? I have an app that also generates a QR code, and I was getting the exact same error:

The filter 'CIPortraitEffectSpillCorrection' is not implemented in the bundle at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/CoreImage/PortraitFilters.cifilter.

Everything seemed to work fine, but the error was annoying, and I couldn't find any solution online. So I just started commenting out block of code until I found a solution.

I'm using code from hackingwithswift.com as a reference (they have some great examples). The odd thing was that I don't remember seeing this error when I first implemented the QR code into my program. But when I moved my higher level declarations for:
        let context = CIContext()
        let filter = CIFilter.qrCodeGenerator()
down into my func generateQRCode scope, the error went away.

Take care.

Whoops. Revision... I still get the error, but not when I run the program, now it's only when I push the button that makes the call. But it only occurs once. Bug?

Check your String.Encoding.ascii
Hey Tillmoss,
I had the same error as you, I had copied some code from Hacking With Swift that I think was out of date. I then found the solution thanks to a YouTube video by the user Jared Davidson. It won't allow me to link to his video but the solution is to do the following :

Code Block
import CoreImage.CIFilterBuiltins
let context = CIContext()
let filter = CIFilter.qrCodeGenerator()
...
private func generateQRCode(from string: String) -> UIImage {
        let data = Data(string.utf8)
        filter.setValue(data, forKey: "inputMessage")
        if let qrCodeImage = filter.outputImage {
            if let qrCodeCGImage = context.createCGImage(qrCodeImage, from: qrCodeImage.extent) {
                return UIImage(cgImage: qrCodeCGImage)
            }
        }
        return UIImage(systemName: "xmark") ?? UIImage()
    }


Just add import CoreImage.CIFilterBuiltins to the top of your file

The filter 'CIPortraitEffectSpillCorrection' is not implemented in the bundle
 
 
Q