SDWebImage / SDWebImageSVGCoder

A SVG coder plugin for SDWebImage, using Apple's built-in framework
MIT License
103 stars 34 forks source link

WidgetKit SVG Image not working #33

Closed ca13ra1 closed 3 years ago

ca13ra1 commented 3 years ago

I'm attempting to get SVG's in SwiftUII for WidgetKit but the images won't load in the widget. It works fine in a SwiftUI app. Getting the yellow and red circle with a line through it. Is this at all possible in WidgetKit.

import SDWebImageSVGCoder
import SDWebImageSwiftUI

struct SVGImage: UIViewRepresentable {
    var url: URL

    func makeUIView(context: Context) -> UIImageView {
        let SVGCoder = SDImageSVGCoder.shared
        SDImageCodersManager.shared.addCoder(SVGCoder)
        let imageView = UIImageView(image: UIImage(systemName: "questionmark"))
        imageView.sd_setImage(with: url, placeholderImage: UIImage(named: "questionmark"))
        return imageView
    }

    func updateUIView(_ uiView: UIImageView, context: Context) {
    }
}