簡體   English   中英

React Native:如何將文件添加到“Xcode 項目根目錄”?

[英]React Native: how do I add a file to “Xcode project root”?

我正在按照本指南向我的 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 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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM