Skip to content

Commit 33d4375

Browse files
committed
When the generated code to load a resource bundle can't find the bundle, it should emit a fatal error rather than crashing the process with a force-unwrap
1 parent d196d9d commit 33d4375

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,11 @@ public final class SwiftTargetBuildDescription {
587587
588588
extension Foundation.Bundle {
589589
static var module: Bundle = {
590-
return Bundle(path: Bundle.main.bundlePath + "/" + "\(bundleBasename)")!
590+
let bundlePath = Bundle.main.bundlePath + "/" + "\(bundleBasename)"
591+
guard let bundle = Bundle(path: bundlePath) else {
592+
fatalError("could not load resource bundle: \\(bundlePath)")
593+
}
594+
return bundle
591595
}()
592596
}
593597
"""

0 commit comments

Comments
 (0)