Is it possible to load Custom made SF Symbols from a web server? Ive quickly tested AsyncImage using SwiftUI
AsyncImage(url: URL.init(string: "https://svgshare.com/i/ouu.svg"))
And it isnt loading anything.
Is it possible to load Custom made SF Symbols from a web server? Ive quickly tested AsyncImage using SwiftUI
AsyncImage(url: URL.init(string: "https://svgshare.com/i/ouu.svg"))
And it isnt loading anything.
First of all, I don't think that AsyncImage
can display SVG images at all.
For example, try:
AsyncImage(url: URL(string: "https://svgshare.com/i/ouu.svg")) { phase in
if let image = phase.image {
image
} else if phase.error != nil {
Text("Error.")
} else {
ProgressView()
}
}
This code displays "Error." with every SVG that I've tried, both from svgshare.com and other websites.
The easy solution is to use on-demand resources. This would, however, require that every symbol that your app could potentially use be included with the app store submission, which may not be what you are looking for.
A more difficult solution would be to host custom bundles remotely, then, as needed, download those, and use something like Image("customSymbol", bundle: downloadedBundle)
. Bundle
objects can be initialized with a URL
, but I don't know if this means that the URL can be on the internet. All the documentation says is, "This must be a full URL for a directory; if it contains any symbolic links, they must be resolvable." It is not clear if the directory can be on a web server. I have no experience with custom bundles, so unfortunately I cannot assist further.
If you find a solution, I would love to learn about it.
Documentation Links: