Xcode 11 PDF image assets "Preserve Vector Data" not working in SwiftUI? : <p>I'm trying to use vector-based PDF images using "Single-Scale" in an app I'm working on using SwiftUI in Xcode 11, but the image always looks blurry when I scale it up in size. </p>

<p>I had no trouble with this in UIKit in Xcode 11. I created a dummy app with 2 scenes, both displaying the same vector image. I created the first scene in a storyboard, then used a HostingViewController to embed an identical scene made in SwiftUI. When I ran the app, the first scene (UIKit) displayed a crisp, non blurry image. The second (SwiftUI) scene however, was blurry and didn't appear to be using vector data, despite using the same source image asset.</p>

<p>I was able to "work around" this by creating a UIImage with the vector image, then using this UIImage extension to resize the UIImage before it's passed into <code>Image</code>. However, the size I enter in the <code>resized(to:)</code> method makes no difference at runtime, so I also have to add <code>.frame(w:,h:)</code> to <code>image</code> in 'var body' to make it show the correct size.</p>

<pre><code>let uiImage = UIImage(named: "Logo-vector")!
var image: Image {
        Image(uiImage: uiImage.resized(to: CGSize(width: 500, height: 500)))
            .resizable()
}

var body: some View {
        NavigationView {
            VStack(alignment: .center, spacing: 8) {
                Spacer()
                Text("Logo vector SwiftUI")
                image
                    .frame(width: 240, height: 216)
                ...
                }
                ...
            }
        }
}

extension UIImage {
    func resized(to size: CGSize) -&gt; UIImage {
        return UIGraphicsImageRenderer(size: size).image { _ in
            draw(in: CGRect(origin: .zero, size: size))
        }
    }
}
</code></pre>

<p>The image is clear and properly resized at runtime with this workaround, but it feels like a bit of a hack.</p>

<p>I've looked everywhere online for a different solution or anyone else having this issue specifically with SwiftUI, but haven't found anything at all.</p>

<p>Has anyone else had this issue or does anyone have a better solution?</p>
