简体   繁体   English

React Native:如何将文件添加到“Xcode 项目根目录”?

[英]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.

相关问题 如何在不使用Xcode的React Native中添加自定义字体? - How do I add custom font in React Native not using Xcode? 如何手动向本地项目添加库? - How do I add a library to react-native project manually? 在PC上完成了React Native项目,现在我想在Mac上使用XCode为Apple Store创建和api文件,我该如何做 - Finished React Native project on PC, now I want to use XCode on my mac to create and api file for the apple store, how do I do this 如何在新 Mac 上通过 Xcode 运行 react native 项目? - How do I run react native project via Xcode on new Mac? 如何在Xcode 9中将项目添加到项目中? - How can I add file to project in Xcode 9? 如何在 React Native 项目中向 info.plist 动态添加权限键和值? - How do I dynamically add permission keys and values to info.plist in a react native project? 如何修改Android和iOS项目,以使条目文件在React Native中成为常见的js文件? - How do I modify android & iOS project to make the entry file as a common js file in react native? 如何继续使用带有xCode的React Native项目进行开发? - How to continue developing with a React Native Project with xCode? 如何将现有的XCode(4.5)项目添加到BitBucket - How do I add an existing XCode (4.5) project to BitBucket 如何向 xcode 项目添加启动画面? - How do i add a splash screen to an xcode project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM