[iOS]: App Extension in new architecture works - but Fabric Text Renderer does not respect any font styles
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
App Extensions do not show font styles correctly
We are currently porting our react-native app from 0.7x to 0.8x, including our app extension to the new architecture which makes use of fabric rendering. We are glad the app extension is now running on RN again. Unfortunately, the app extension does not display Labels correctly.
I assume this issue is related to the new Fabric Text Renderer. For some reason it is correctly displaying the font styles when the main target (normal RN app) is executed, but not from the app extension.
All the view styles are applied correctly, e.g. button styles, background video, etc., but the fonts are not applied or even invisible (if a custom fontFamily property is provided, even if it's just 'Arial')
I temporarily added some logging in the RCTFont.mm but nothing appeared in the console.
It was quite a hassle to get it working at all. We did days of digging to make it work and we are sharing our insights in the attached repro.
Summary of steps to create the extension:
- Use Obj-C++ class that uses
RCTReactNativeFactoryto create a react-native instance using new architecture, also make use ofRCTDefaultReactNativeFactoryDelegateto tell where to load the main.jsbundle from - Exposed a simple API that can be used by our swift class, which is a subclass of
ASCredentialProviderViewController - Add bridging header
- Make modifications in the podfile (mentioning the target, making sure it's using the same RN deps, and disabling a property
APPLICATION_EXTENSION_API_ONLY)
Additional Notes:
Also I would recommend maybe creating guards around UIApplication sharedApplication in RCTScrollView around line 315, since it will emit
"sharedApplication is unavailable: not available on iOS (App Extension) - use view controller based solutions where appropriate".
Currently I changed the build settings of the app extension: Require Only App-Extension-Safe API = NO
(see Podfile provided in repro)
Steps to reproduce
- Run the packager "yarn start"
- Open the workspace in Xcode
- Due to appstore requirements, you will have to select a valid team for both the app extension and the main target
- Build for simulator, e.g. iPhone 16 Pro
- Select the correct build scheme
- Select Safari as a target
- Safari will open, now visit https://m.facebook.com
- Tap into the username field
- Make sure the keyboard appears (I do this always with CMD+K)
- Press "Passwords"
- The app will popup, it will show the fonts
As you can see, the styling isn't applied, although it's clearly defined in the App.jsx.
When a custom custom font is specified, the font disappears completely.
import React from 'react';
import {
Text,
View,
} from 'react-native';
function App() {
return (
<View
style={{
flex: 1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center',
}}>
<Text style={{fontSize: 30, color: 'black'}}>ABCDEF (fs=30)</Text>
<Text style={{fontSize: 12, color: 'black', marginTop: 16}}>
GHIJKLM (fs=12)
</Text>
<Text style={{fontSize: 30, color: 'black', fontFamily: 'Arial'}}>BONUS (font family)</Text>
</View>
);
}
export default App;
When the main app is run, it will be displayed correctly.
React Native Version
0.82.1
Affected Platforms
Runtime - iOS
Areas
Fabric - The New Renderer
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.6
CPU: (10) arm64 Apple M1 Max
Memory: 1.05 GB / 64.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.19.0
path: /Users/yoshijaeger/.nvm/versions/node/v22.19.0/bin/node
Yarn:
version: 1.22.22
path: /Users/yoshijaeger/.yarn/bin/yarn
npm:
version: 10.9.3
path: /Users/yoshijaeger/.nvm/versions/node/v22.19.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.25410.109.2511.13665796
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.15
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.1
wanted: 19.1.1
react-native:
installed: 0.82.1
wanted: 0.82.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
Unfortunately no significant logs
Unbalanced calls start/end for tag 20
Unbalanced calls start/end for tag 19
Running "RNFontIssueRepro" with {"rootTag":11,"initialProps":{},"fabric":true}
MANDATORY Reproducer
https://github.com/SmartArray/rn-appext-fabric-font-repro
Screenshots and Videos
_Screenshots provided in "how to reproduce" (Steps) and in main issue description _
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
按照列出的 Xcode 和模拟器步骤运行必需的 reproducer,然后使用 App.jsx 中的样式将扩展与主目标进行比较。检查 RCTFont.mm 中提到的 logging 区域以及 RCTScrollView 的警告上下文。当字体大小、颜色和自定义 fontFamily 在应用扩展中正确渲染,且不再出现报告的警告问题时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp, ios, objective-c, react-native, swift
- 领域
- frontend, mobile-dev
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100