Use placeholder app icon in view in Swift Playgrounds 4

I’m trying to use the placeholder app icon in a SwiftUI view using Swift Playgrounds 4 on iPad. I’ve tried using Image(“AppIcon”), but that hasn’t worked, nothing appears.

What’s weird is that when trying to import a photo and name it AppIcon, I get this pop up:

"Applcon-1.imageset" couldn't be moved to "Assets.xcassets" because an item with the same name already exists. To save the file, either provide a different name, or move aside or delete the existing file, and try again.

If anyone has been able to solve it, I will appreciate it!

Try

Image(“AppIcon-1”)

I'm not sure how iOS handles that, but it seems the iOS App Icon resource with name AppIcon in Assets.xcassets is handled specially by iOS and you cannot access it from inside your app.

If you want to use it as Image("..."), you may need to create an Image Set resource with another name than AppIcon, and copy the same image into it.

Image(uiImage: UIImage(named: "AppIcon") ?? UIImage()) works fine

Use placeholder app icon in view in Swift Playgrounds 4
 
 
Q