react-native iOS 应用程序在部署后不显示静态/本地资产(图像) [英] react-native iOS app not showing static/local assets (images) after deploying

查看:57
本文介绍了react-native iOS 应用程序在部署后不显示静态/本地资产(图像)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的所有静态图像都位于项目根目录中名为images"的文件夹中.但是,在我运行以下命令捆绑我的应用程序后,该应用程序可以运行,但没有显示图像.

I have all my static images in a folder called "images" in the root of my project. However, after I run the following command to bundle my app, the app works but no image is shown.

我用来打包的命令:

./react-native bundle --minify --entry-file index.ios.js --platform ios --dev false --bundle-output main.jsbundle --assets-dest ./assets

请注意,资产文件夹已创建,其中包含我的所有图像都正常的图像文件夹.

Note that the assets folder is created and it has my images folder with all images ok.

你能帮忙吗?

推荐答案

资产目标和 main.jsbundle 必须在同一文件夹中.试试:

The asset destination and the main.jsbundle have to be in the same folder. Try:

./react-native bundle --minify --entry-file index.ios.js --platform ios --dev false --bundle-output ./release/main.jsbundle --assets-dest ./release

打包器无论如何都会在那里创建一个资产文件夹.

The bundler will create an assets folder in there anyway.

更新,包括来自以下讨论的信息:

UPDATE including information from the discussions below:

在 XCode 构建步骤中执行的 react-native-xcode.sh 脚本将 main.jsbundle 和捆绑器创建的资产文件夹复制到应用程序包中.如果您想手动部署包,您需要确保复制这些文件.最简单的方法是将 main.jsbundle 直接包含到项目中,并创建一个指向 assets 文件夹的文件夹链接.验证两者都显示在构建阶段"->复制捆绑资源"中.

The react-native-xcode.sh script that is executed in a XCode build step copies the main.jsbundle and the assets folder created by the bundler into the app package. If you want to deploy the package manually you need to make sure, that those files are copied. The easiest way is to include the main.jsbundle directly into the project and create a folder link to the assets folder. Verify that both are showing up in 'Build Phases' -> 'Copy Bundle Resources'.

这篇关于react-native iOS 应用程序在部署后不显示静态/本地资产(图像)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆