File tree Expand file tree Collapse file tree 6 files changed +30
-1
lines changed
Fixtures/Resources/Simple Expand file tree Collapse file tree 6 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -17,5 +17,12 @@ let package = Package(
17
17
. copy( " foo.txt " ) ,
18
18
]
19
19
) ,
20
+
21
+ . target(
22
+ name: " CPPResource " ,
23
+ resources: [
24
+ . copy( " foo.txt " ) ,
25
+ ]
26
+ ) ,
20
27
]
21
28
)
Original file line number Diff line number Diff line change
1
+ foo
Original file line number Diff line number Diff line change
1
+ #import < Foundation/Foundation.h>
2
+
3
+ int main (int argc, const char * argv[]) {
4
+ @autoreleasepool {
5
+ NSBundle *bundle = SWIFTPM_MODULE_BUNDLE;
6
+ NSString *foo = [bundle pathForResource: @" foo" ofType: @" txt" ];
7
+ NSData *data = [NSFileManager .defaultManager contentsAtPath: foo];
8
+ NSString *contents = [[NSString alloc ] initWithData: data encoding: NSUTF8StringEncoding];
9
+ printf (" %s" , contents.UTF8String );
10
+ }
11
+ return 0 ;
12
+ }
Original file line number Diff line number Diff line change @@ -471,9 +471,17 @@ public final class ClangTargetBuildDescription {
471
471
headerFileStream <<< """
472
472
#import <Foundation/Foundation.h>
473
473
474
+ #if __cplusplus
475
+ extern " C " {
476
+ #endif
477
+
474
478
NSBundle* \( target. c99name) _SWIFTPM_MODULE_BUNDLE(void);
475
479
476
480
#define SWIFTPM_MODULE_BUNDLE \( target. c99name) _SWIFTPM_MODULE_BUNDLE()
481
+
482
+ #if __cplusplus
483
+ }
484
+ #endif
477
485
"""
478
486
let headerFile = derivedSources. root. appending ( component: " resource_bundle_accessor.h " )
479
487
self . resourceAccessorHeaderFile = headerFile
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ public struct Sources: Codable {
46
46
guard let ext = $0. extension else {
47
47
return false
48
48
}
49
- return ext == SupportedLanguageExtension . m. rawValue
49
+ return ext == SupportedLanguageExtension . m. rawValue || ext == SupportedLanguageExtension . mm . rawValue
50
50
} )
51
51
}
52
52
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class ResourcesTests: XCTestCase {
21
21
// Objective-C module requires macOS
22
22
#if os(macOS)
23
23
executables. append ( " SeaResource " )
24
+ executables. append ( " CPPResource " )
24
25
#endif
25
26
26
27
for execName in executables {
You can’t perform that action at this time.
0 commit comments