Load Images Asynchronously in SwiftUI v3

Published June 9, 2021

SwiftUI version 3 (coming in iOS 15 & macOS Monterey) has brought with it many nice features, including AsyncImage, which greatly simplifies the process of downloading and displaying remote images from the internet:

let imageURL = URL(string: "<exampleURL>")
//...
AsyncImage(url: url) { image in
  image
    .resizable()
    .aspectRatio(contentMode: .fill)
} placeholder: {
  Color.red
}
.frame(width: 200, height: 200)

In the above example a red placeholder view is shown while the image is loading.