Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions Sources/WordPressSharedObjC/Utility/WPFontManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ + (void)loadFontNamed:(NSString *)fontName resourceNamed:(NSString *)resourceNam

+ (void)loadFontResourceNamed:(NSString *)name withExtension:(NSString *)extension
{
#if SWIFT_PACKAGE
NSBundle *bundle = SWIFTPM_MODULE_BUNDLE;
#else
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
#endif
NSURL *url = [bundle URLForResource:name withExtension:extension];
NSURL *url = [[self resourceBundle] URLForResource:name withExtension:extension];

CFErrorRef error;
if (!CTFontManagerRegisterFontsForURL((CFURLRef)url, kCTFontManagerScopeProcess, &error)) {
Expand All @@ -125,4 +120,20 @@ + (void)loadFontResourceNamed:(NSString *)name withExtension:(NSString *)extensi
return;
}

+ (NSBundle *)resourceBundle {
#if SWIFT_PACKAGE
return SWIFTPM_MODULE_BUNDLE;
#else
// When installed via CocoaPods, the resources will be bundled under `WordPressShared.bundle`.
// This follows the implementation from `NSBundle+WordPressShared`.
NSBundle *defaultBundle = [NSBundle bundleForClass:[self class]];
NSURL *sharedBundleURL = [defaultBundle.bundleURL URLByAppendingPathComponent:@"WordPressShared.bundle"];
NSBundle *sharedBundle = [NSBundle bundleWithURL:sharedBundleURL];
if (sharedBundle) {
return sharedBundle;
}
return defaultBundle;
#endif
}

@end
2 changes: 1 addition & 1 deletion WordPressShared.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Pod::Spec.new do |s|
s.name = 'WordPressShared'
s.version = '2.0.0'
s.version = '2.0.1-beta.1'

s.summary = 'Shared components used in building the WordPress iOS apps and other library components.'
s.description = <<-DESC
Expand Down