If I use the Bundle.module.url()
API from my code on Windows, I noticed that it generates absolute paths to the resource bundle:
extension Foundation.Bundle {
static var module: Bundle = {
let mainPath = "C:/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin\\ABC_XYZ.resources"
let buildPath = "C:\\Users\\pcbea\\Trees\\ABC\\.build\\x86_64-unknown-windows-msvc\\release\\ABC_XYX.resources"
let preferredBundle = Bundle(path: mainPath)
guard let bundle = preferredBundle != nil ? preferredBundle : Bundle(path: buildPath) else {
fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)")
}
return bundle
}()
}
Wouldn't it be better to look relative to Bundle.main? I can imagine this approach is fine for debugging, but how would one ever deploy with this approach?