ios - React Native:如何将文件添加到“Xcode 项目根目录”?
问题描述
我正在按照本指南向我的 React Native 项目添加自定义推送通知声音。它说要拿走我的.wav
文件和Add files to the Xcode project root. Make sure Add to targets is selected when adding files so that they are automatically add to the bundle resources
. 谁能准确解释如何做到这一点?我是否将文件拖放到 XCode 文件结构中的特定位置?
解决方案
是的。如果您将文件拖放到.wav
主项目文件夹(在哪里Info.plist
),那么您将能够像这样在 Javascript 中访问该文件:
import RNFS from 'react-native-fs';
const fileName = `${RNFS.DocumentDirectoryPath}/yourFile.wav`
检查它是否存在:
const exists = await RNFS.exists(fileName);
推荐阅读
- spring - Spring集成文件拆分器锁
- php - 如何避免在浏览器中预览 pdf 并使用 dompdf 将其保存在文件夹中
- ruby - 字符串操作和`eval`
- c++ - 添加异常后的奇怪行为
- google-apps-script - 谷歌表格“需要权限”才能为共享用户运行容器绑定脚本
- python - Django:一起返回响应和返回反向
- macos - 升级后无法在 Mac 10.14 Mojave 上永久禁用 httpd
- linux - Bash 验证用户输入
- postgresql - Postgres regr_slope 返回 NULL
- c# - 将大文件从 asp.net web api 2 控制器传递给静态方法