3

I have a framework that imports several Swift Packages.

One such package uses Bundle.myModule for resources. Here is the code use for .myModule

extension Foundation.Bundle {
static var myModule: Bundle = {
    let bundleNameIOS = "xxxx"
    let candidates = [
        // Bundle should be present here when the package is linked into an App.
        Bundle.main.resourceURL,
        // Bundle should be present here when the package is linked into a framework.
        Bundle(for: CurrentBundleFinder.self).resourceURL,
        // Bundle should be present here for package UI Tests.
        Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent(),
        // For command-line tools. */
        Bundle.main.bundleURL,
        // Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/").
        Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent(),
        Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent(),
    ]

    for candidate in candidates {
        let bundlePathiOS = candidate?.appendingPathComponent(bundleNameIOS + ".bundle")
        if let bundle = bundlePathiOS.flatMap(Bundle.init(url:)) {
            return bundle
        }

        if let bundle = Bundle(path: "\(Bundle.main.bundlePath)/\(bundleNameIOS).bundle") {
            return bundle
        }
    }
    fatalError("unable to find bundle")
}()

}

Then we I build the framework and embed it inside another project I get the error

Fatal error: unable to find bundle

But the Package that this is failing in is inside the XCFramework

the folder path "App/Frameworks/myFramework" does not contain any bundles

I have tried all of the follow:

Please any help would be greatly appreciated. Thank you

Malcolmn Roberts
  • 354
  • 3
  • 11

0 Answers0