SWIFTPM_MODULE_BUNDLE now seems to work for ObjC++

This commit is contained in:
Taylor Holliday 2023-04-20 16:06:54 -07:00
parent aa33f717c3
commit b499d9b985
6 changed files with 4 additions and 42 deletions

View File

@ -1,15 +0,0 @@
// Copyright © 2021 Audulus LLC. All rights reserved.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Accessing SWIFTPM_MODULE_BUNDLE from ObjC++ doesn't work for some reason.
/// See https://forums.swift.org/t/undefined-symbol-package-module-swiftpm-module-bundle/45773
@interface vgerBundleHelper : NSObject
+ (NSBundle*) moduleBundle;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,17 +0,0 @@
// Copyright © 2021 Audulus LLC. All rights reserved.
#import "vgerBundleHelper.h"
@implementation vgerBundleHelper
+ (NSBundle*) moduleBundle {
#ifdef SWIFTPM_MODULE_BUNDLE
NSBundle* bundle = SWIFTPM_MODULE_BUNDLE;
#else
NSBundle* bundle = [NSBundle mainBundle];
#endif
assert(bundle);
return bundle;
}
@end

View File

@ -2,7 +2,6 @@
#import "vgerGlyphCache.h"
#import "vgerTextureManager.h"
#import "vgerBundleHelper.h"
#include <vector>
@interface vgerGlyphCache() {
@ -19,9 +18,8 @@
if (self) {
mgr = [[vgerTextureManager alloc] initWithDevice:device pixelFormat:MTLPixelFormatA8Unorm];
auto bundle = [vgerBundleHelper moduleBundle];
auto bundle = SWIFTPM_MODULE_BUNDLE;
assert(bundle);
auto fontURL = [bundle URLForResource:@"Anodina-Regular" withExtension:@"ttf" subdirectory:@"fonts"];
auto fd = CTFontManagerCreateFontDescriptorsFromURL( (__bridge CFURLRef) fontURL);

View File

@ -1,16 +1,14 @@
// Copyright © 2021 Audulus LLC. All rights reserved.
#import "vgerGlyphPathCache.h"
#import "vgerBundleHelper.h"
#import "sdf.h"
using namespace simd;
vgerGlyphPathCache::vgerGlyphPathCache() {
auto bundle = [vgerBundleHelper moduleBundle];
auto bundle = SWIFTPM_MODULE_BUNDLE;
assert(bundle);
auto fontURL = [bundle URLForResource:@"Anodina-Regular" withExtension:@"ttf" subdirectory:@"fonts"];
auto fd = CTFontManagerCreateFontDescriptorsFromURL( (__bridge CFURLRef) fontURL);

View File

@ -1,13 +1,12 @@
// Copyright © 2021 Audulus LLC. All rights reserved.
#import "vgerRenderer.h"
#import "vgerBundleHelper.h"
#import "paint.h"
#import "prim.h"
static id<MTLLibrary> GetMetalLibrary(id<MTLDevice> device) {
auto bundle = [vgerBundleHelper moduleBundle];
auto bundle = SWIFTPM_MODULE_BUNDLE;
assert(bundle);
auto libraryURL = [bundle URLForResource:@"default" withExtension:@"metallib"];

View File

@ -1,12 +1,11 @@
// Copyright © 2021 Audulus LLC. All rights reserved.
#import "vgerTileRenderer.h"
#import "vgerBundleHelper.h"
#import "commands.h"
static id<MTLLibrary> GetMetalLibrary(id<MTLDevice> device) {
auto bundle = [vgerBundleHelper moduleBundle];
auto bundle = SWIFTPM_MODULE_BUNDLE;
assert(bundle);
auto libraryURL = [bundle URLForResource:@"default" withExtension:@"metallib"];