Skip to content

Commit 6429af2

Browse files
committed
Fix resource bundle accessor issue for Clang sources
- I noticed an issue when trying to access a Clang package's resources when testing the target from the SwiftPM CLI. In short, the resource bundle is placed in the same place when building a Clang-only or Swift-only package, but the generated resource_bundle_accessor.m's logic tries to create an NSBundle for a path that DNE. The difference becomes clear when comparing the logic to the resource_bundle_accessor.swift that is generated from Swift-only packages with resources.
1 parent 91156ab commit 6429af2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,13 @@ public final class ClangTargetBuildDescription {
554554
555555
NSBundle* \(target.c99name)_SWIFTPM_MODULE_BUNDLE() {
556556
NSURL *bundleURL = [[[NSBundle mainBundle] bundleURL] URLByAppendingPathComponent:@"\(bundleBasename)"];
557-
return [NSBundle bundleWithURL:bundleURL];
557+
558+
NSBundle *preferredBundle = [NSBundle bundleWithURL:bundleURL];
559+
if (preferredBundle == nil) {
560+
return [NSBundle bundleWithPath:@"\(bundlePath.pathString)"];
561+
}
562+
563+
return preferredBundle;
558564
}
559565
"""
560566

0 commit comments

Comments
 (0)