Bunlde.module In Swift Package Crashes The App

I have a Swift Package for a small feature that I'd like to use in multiple apps. All I want is to present the ViewController inside the Swift package from the app that uses it.

It works fine while developing, but when creating an ipa for the app or submitting to the App Store, it stops working, and it caused the app to be rejected.

In the Swift Package I have this extension to get a view controller's storyboard:
Code Block
public extension UIViewController{
    static func getStoryboardVC() -> UIViewController {
let storyboard = UIStoryboard(name: String(describing: self), bundle: Bundle.module)
        return storyboard.instantiateInitialViewController()!
    }
}


and in the app I get the Swift Package's view controller like this:

Code Block        
let vc = ARMap.ARCameraVC.getStoryboardVC() 
present(vc, animated: true, completion: nil)

This works great when building in Xcode into a device, but when installing the app as an .ipa file, or submitting to the App Store it crashes with this error from the device logs:

Fatal error: unable to find bundle named ARMap_ARMap: file ARMap/resource_bundle_accessor.swift, line 27


The resource_bundle_accessor that was generated looks like this:

Code Block private class BundleFinder {}
extension Foundation.Bundle {
    static var module: Bundle = {
        let bundleName = "ARMap_ARMap"
        let candidates = [
            Bundle.main.resourceURL,
            Bundle(for: BundleFinder.self).resourceURL,
            // For command-line tools.
            Bundle.main.bundleURL,
        ]
        for candidate in candidates {
            let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
            if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
                return bundle
            }
        }
        fatalError("unable to find bundle named ARMap_ARMap")
    }()
}


The targets in the package's manifest looks like this:

Code Block     targets: [
        .target(
            name: "ARMap",
            dependencies: [],
            resources: [.process("Resources")]
        ),
        .testTarget(
            name: "ARMapTests",
            dependencies: ["ARMap"]),
    ]



I hope someone can spot what I'm doing wrong.


Answered by fullmoon14 in 663577022
I solved it with the magic of starting fresh hehe. I was using the Swift Package with an App Clip. All I did was deleting the App Clip and creating it again. I linked the Swift Package to it, and bam it's working in .ipa exported file and the App Store didn't complain.
Accepted Answer
I solved it with the magic of starting fresh hehe. I was using the Swift Package with an App Clip. All I did was deleting the App Clip and creating it again. I linked the Swift Package to it, and bam it's working in .ipa exported file and the App Store didn't complain.
Bunlde.module In Swift Package Crashes The App
 
 
Q