Package with "-" in name has "_" in bundle name in resource_bundle_accessor.m for Obj-C target

I have a problem with SWIFTPM_MODULE_BUNDLE not finding the Bundle.

It seems the resource_bundle_accessor.m uses the wrong path by replacing "-" with "_" in the package name to set the bundleName NSString variable. I searched for this code in the open-source SPM repo, but the implementation of the resource_bundle_accessor there is different. I couldn't find this in the history as well.

The bundle exists as swift-ensembles_EnsemblesTests.

Xcode: 13.2 (13C90) (I don't currently use Xcode 13.3 as it keeps crashing, but I'll try it later)


#import <Foundation/Foundation.h>


@interface swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLER_FINDER : NSObject

@implementation swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLER_FINDER

NSBundle* swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLE() {
    NSString *bundleName = @"swift_ensembles_EnsemblesTests";

    NSArray<NSURL*> *candidates = @[
        [NSBundle bundleForClass:[swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLER_FINDER class]].resourceURL,

    for (NSURL* candiate in candidates) {
        NSURL *bundlePath = [candiate URLByAppendingPathComponent:[NSString stringWithFormat:@"%@.bundle", bundleName]];

        NSBundle *bundle = [NSBundle bundleWithURL:bundlePath];
        if (bundle != nil) {
            return bundle;

    @throw [[NSException alloc] initWithName:@"SwiftPMResourcesAccessor" reason:[NSString stringWithFormat:@"unable to find bundle named %@", bundleName] userInfo:nil];



// swift-tools-version: 5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "swift-ensembles",
    products: [
        .library(name: "Ensembles", targets: ["Ensembles"]),
    dependencies: [],
    targets: [
            name: "Ensembles",
            dependencies: [],
            resources: [
            publicHeadersPath: "include",
            cSettings: [
                .headerSearchPath("./Source/Cloud File Systems"),
            name: "EnsemblesTests",
            dependencies: ["Ensembles"],
            resources: [
                .process("Integrator Test Fixtures")