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)
resource_bundle_accessor.m
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLER_FINDER : NSObject
@end
@implementation swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLER_FINDER
@end
NSBundle* swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLE() {
NSString *bundleName = @"swift_ensembles_EnsemblesTests";
NSArray<NSURL*> *candidates = @[
NSBundle.mainBundle.resourceURL,
[NSBundle bundleForClass:[swift_ensembles_EnsemblesTests_SWIFTPM_MODULE_BUNDLER_FINDER class]].resourceURL,
NSBundle.mainBundle.bundleURL
];
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];
}
NS_ASSUME_NONNULL_END
Package.swift
// 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: [
.target(
name: "Ensembles",
dependencies: [],
resources: [
.process("Resources")
],
publicHeadersPath: "include",
cSettings: [
.headerSearchPath("./Source/Baselines"),
.headerSearchPath("./Source/Cloud"),
.headerSearchPath("./Source/Cloud File Systems"),
.headerSearchPath("./Source/Ensemble"),
.headerSearchPath("./Source/Events"),
.headerSearchPath("./Source/General"),
.headerSearchPath("./Source/Model"),
.headerSearchPath("./Source/Revisioning"),
]
),
.testTarget(
name: "EnsemblesTests",
dependencies: ["Ensembles"],
resources: [
.process("Integrator Test Fixtures")
]
),
]
)