本文档介绍了 Gutenberg 仓库中基于 React Native 的移动编辑器,重点强调了在代码重构时需手动更新原生移动文件以避免客户端崩溃,并提供了运行、测试和调试移动编辑器的指导。
// 示例:平台特定文件命名
// 通用文件:editor.js
// 移动端特定:editor.native.js
// Android 特定:editor.android.js
// iOS 特定:editor.ios.jsThe Gutenberg repository includes the source for the React Native based editor for mobile.
Contributors need to ensure that they update any affected native mobile files during code refactorings because we cannot yet rely on automated tooling to do this for us. For example, renaming a function or a prop should also be performed in the native modules too, otherwise, the mobile client will break. We have added some mobile specific CI tests as safeguards in place in PRs, but we’re still far from done. Please bear with us and thank you in advance. ❤️🙇
The majority of the code shared with native mobile is in the very same JavaScript module and SASS style files. In the cases where the code paths need to diverge, a .native.js or .native.scss variant of the file is created. In some cases, platform specific files can be also found for Android (.android.js) or iOS (.ios.js).
For instructions on how to run the Gutenberg Mobile Demo App on Android or iOS, see Getting Started for the React Native based Mobile Gutenberg
Also, the mobile client is packaged and released via the official WordPress apps. Even though the build pipeline is slightly different then the mobile demo apps and lives in its own repo for now (here’s the native mobile repo), the source code itself is taken directly from this repo and the “web” side codepaths.
If you encounter a failed Android/iOS test on your pull request, we recommend the following steps:
.native.js versions of files.Follow the instructions in Native mobile testing to locally debug the native mobile unit tests when needed.
Further information about this topic can be found in the React Native Internationalization Guide.