我有一个 Expo 项目,其中的<Image />组件来自导入:
import logoImage from './assets/logo-medium.png';
...
<Image source={logoImage} />
Run Code Online (Sandbox Code Playgroud)
当使用 进行构建时,这在我的设备上运行良好expo run:ios -d。但是,当我使用 XCode 构建项目时,图像不存在,并且我看到以下错误:
[native] Could not find image file:///Users/username/Library/Developer/CoreSimulator/Devices/B76D59AF-9599-4174-991B-AE484575B79C/data/Containers/Data/Application/A57C6E10-3DF9-46E0-8B56-7760AF5199C6/Library/Application%20Support/.expo-internal/assets/assets/logo-medium.png
Run Code Online (Sandbox Code Playgroud)
当我尝试手动查找该文件时,没有...Application Support/.expo-internal目录。
我应该有不同的方式来指定图像位置吗?或者从 XCode 构建时正确捆绑图像的方法?
我遇到了同样的问题,请确保两件事:
Run Code Online (Sandbox Code Playgroud)Ok I found out the problem. When ejecting, expo is supposed to generate a metro.config.js file that looks like that: module.exports = { transformer: { assetPlugins: ['expo-asset/tools/hashAssetFiles'] } };
metro.config.js文件.js不应有扩展名.ts| 归档时间: |
|
| 查看次数: |
1533 次 |
| 最近记录: |