[英]React Native: how do I add a file to “Xcode project root”?
I'm following this guide to add custom push notification sounds to my React Native project.我正在按照本指南向我的 React Native 项目添加自定义推送通知声音。 It says to take my
.wav
file and 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
它说要获取我的
.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
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
. 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
中。 Can anyone explain exactly how to do this?谁能准确解释如何做到这一点? Do I drag and drop the file to a specific spot in the file structure in XCode?
我是否将文件拖放到 XCode 文件结构中的特定位置?
Yes.是的。 If you drag and drop your
.wav
file under your main project folder (where Info.plist
is) then you'll be able to access this file in Javascript like this:如果您将
.wav
文件拖放到主项目文件夹( Info.plist
所在的位置)下,那么您将能够在 Javascript 中访问此文件,如下所示:
import RNFS from 'react-native-fs';
const fileName = `${RNFS.DocumentDirectoryPath}/yourFile.wav`
Check if it exists:检查它是否存在:
const exists = await RNFS.exists(fileName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.