'Runtime Error: SwiftUI: No image named '' found in asset catalog for main bundle
This is the error I'm getting:

runtime: SwiftUI: No image named '' found in asset catalog for main bundle (/Users/yun/Library/Developer/CoreSimulator/Devices/623B1BB3-5C34-4311-AA41-86C42FE27439/data/Containers/Bundle/Application/8E87B349-36CA-41B8-A34C-02BBB2F00472/Travel.app)
The image doesn't have a name, just '', so I can't find the cause of the error.
// AppDelegate.swift <br>
class AppDelegate: UIResponder, UIApplicationDelegate { <-- this is the break point...
Solution 1:[1]
The error that you are receiving means that somewhere in your code you are initiating an Image("some name") and passing in an empty string "".
Try a search for Image( in Xcode and see if there are any Image views maybe, with default values that are blank.
Also, if you really want to debug this issue, and find the missing image name among potentially thousands of lines of code, you can try out this nifty extension:
#if DEBUG
extension Image {
init(_ str: String) {
guard let img = UIImage(named: str) else {
print(str)
fatalError("found an image that doesn't exist, see: https://stackoverflow.com/a/63006278/11161266")
}
self.init(uiImage: img)
}
init(systemName sys: String) {
guard let img = UIImage(systemName: sys) else {
print(sys)
fatalError("found an image that doesn't exist, see: https://stackoverflow.com/a/63006278/11161266")
}
self.init(uiImage: img)
}
}
#endif
It will force a crash when it finds a missing image, and you can navigate directly to the line of code that caused it:
Alternatively, you could easily modify the above extension to provide a default value to all your empty images:
extension Image {
init(_ str: String) {
self.init(uiImage:
UIImage(named: str) ?? UIImage(named: "Some default image")!
)
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

