This repository was archived by the owner on Jun 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Sources/WordPressSharedObjC/Utility Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,12 +108,7 @@ + (void)loadFontNamed:(NSString *)fontName resourceNamed:(NSString *)resourceNam
108108
109109+ (void )loadFontResourceNamed : (NSString *)name withExtension : (NSString *)extension
110110{
111- #if SWIFT_PACKAGE
112- NSBundle *bundle = SWIFTPM_MODULE_BUNDLE;
113- #else
114- NSBundle *bundle = [NSBundle bundleForClass: [self class ]];
115- #endif
116- NSURL *url = [bundle URLForResource: name withExtension: extension];
111+ NSURL *url = [[self resourceBundle ] URLForResource: name withExtension: extension];
117112
118113 CFErrorRef error;
119114 if (!CTFontManagerRegisterFontsForURL ((CFURLRef)url, kCTFontManagerScopeProcess , &error)) {
@@ -125,4 +120,20 @@ + (void)loadFontResourceNamed:(NSString *)name withExtension:(NSString *)extensi
125120 return ;
126121}
127122
123+ + (NSBundle *)resourceBundle {
124+ #if SWIFT_PACKAGE
125+ return SWIFTPM_MODULE_BUNDLE;
126+ #else
127+ // When installed via CocoaPods, the resources will be bundled under `WordPressShared.bundle`.
128+ // This follows the implementation from `NSBundle+WordPressShared`.
129+ NSBundle *defaultBundle = [NSBundle bundleForClass: [self class ]];
130+ NSURL *sharedBundleURL = [defaultBundle.resourceURL URLByAppendingPathComponent: @" WordPressShared.bundle" ];
131+ NSBundle *sharedBundle = [NSBundle bundleWithURL: sharedBundleURL];
132+ if (sharedBundle) {
133+ return sharedBundle;
134+ }
135+ return defaultBundle;
136+ #endif
137+ }
138+
128139@end
Original file line number Diff line number Diff line change 44
55Pod ::Spec . new do |s |
66 s . name = 'WordPressShared'
7- s . version = '2.0.0 '
7+ s . version = '2.0.1-beta.1 '
88
99 s . summary = 'Shared components used in building the WordPress iOS apps and other library components.'
1010 s . description = <<-DESC
You can’t perform that action at this time.
0 commit comments