wordpress-mobile / WordPress-iOS-Shared

Shared components used in building the WordPress iOS apps and other library components
GNU General Public License v2.0
18 stars 22 forks source link

Fix resource bundle for WordPressShared when installed from CocoaPods #331

Closed dvdchr closed 1 year ago

dvdchr commented 1 year ago

Refs https://github.com/wordpress-mobile/WordPress-iOS/issues/19877, p5T066-3ND-p2#comment-14170, p5T066-3ND-p2#comment-14172

This fixes an issue where the WordPressShared no longer loads the Noto font family correctly, resulting in the app content (editor, comment threads) being displayed with the default font from HTML.

In 1.18.0, WPFontManager loads the bundle was loaded through this method:

https://github.com/wordpress-mobile/WordPress-iOS-Shared/blob/3ed6530c1cb7a56c632afad808b279074692d0a3/WordPressShared/Core/Utility/WPFontManager.m#L113

However, the method has since been moved to the Swift part in WordPressShared, and is inaccessible from WPFontManager because the font manager is inside WordPressSharedObjC which is depended upon by WordPressShared, but not the other way around. CMIIW.

When debugging the app, the fonts are located in WordPress.app/WordPressShared.bundle since the WordPressShared is still included through CocoaPods. Following the solution from NSBundle+WordPressShared.swift, this attempts to add the WordPressShared.bundle to the bundle path when loading the font.

To Test

Refer to https://github.com/wordpress-mobile/WordPress-iOS/pull/19898.


crazytonyli commented 1 year ago

Ops, my bad, not sure why I replaced the original wordPressSharedBundle call with bundleForClass:... Thanks for the fix!