反应原生iOS应用程序部署后不显示静态资源(图像) [英] react-native iOS app not showing static assets (images) after deploying

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

问题描述

我的所有静态图像都在我的项目根目录下的一个名为images的文件夹中。但是,在运行以下命令捆绑我的应用程序后,应用程序可以正常工作,但没有显示图像。



我用来捆绑的命令:

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

请注意,资产文件夹已创建,我的图像文件夹中的所有图像都可以。



你能帮助吗?

解决方案

资产目的地和mainbundle.js必须在同一个文件夹中。尝试:

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

捆绑者将在那里创建一个资产文件夹。



更新包括以下讨论中的信息:



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


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.

The command I use to bundle:

./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.

Can you help please?

解决方案

The asset destination and the mainbundle.js 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:

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'.

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

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