Assets missing only in iOS release build after ejecting

Hi,

I recently ejected from expo 38 and since then my static images are not showing when I run the app in release mode on iOS, no errors are reported either. Works fine on Android for both release and debug.

When I print the uri of an image it points to APP_ID/Library/Application Support/.expo-internal/assets/assets/my-image.png.
Inside my simulator there’s no assets folder inside .expo-internal however all my assets are there at the root of .expo-internal with their original names replaced by hexadecimal strings (ex: 24d3a85009cdd5cd76c2e066c450de2d.png).

I’ve tried to build an offline bundle and adding it to Copy Bundle Resources in Build Phases as explained here but to no avail.

Here is the expo diagnostics:
Expo CLI 3.25.1 environment info:
System:
OS: macOS 10.15.5
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.18.3 - /usr/local/opt/node@12/bin/node
npm: 6.14.6 - /usr/local/opt/node@12/bin/npm
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
npmPackages:
expo: ^38.0.8 => 38.0.9
react: ~16.11.0 => 16.11.0
react-dom: 16.11.0 => 16.11.0
react-native: ~0.62.2 => 0.62.2
react-native-web: ~0.11.7 => 0.11.7
npmGlobalPackages:
expo-cli: 3.25.1

Is there a way to make the assets keep their initial names and go to where the uris are pointing to ?

Thank you.

1 Like

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']
    }
};

I presume it makes sure the assets are bundled correctly.
However I already had a metro.config.js file prior to ejecting that I needed for a svg library so expo didn’t generate a new one.

In future version of expo it would be practical if the eject process could add the necessary configuration inside the metro.config.js if the file already exists.

4 Likes

This worked for me

1 Like

:partying_face:

I have a very similar setup to you but already have an identical metro.config.js, yet the images remain hidden

Expo CLI 3.27.14 environment info:
System:
OS: macOS 10.15.7
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 6.14.7 - ~/.nvm/versions/node/v12.13.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
npmPackages:
expo: ^38.0.2 => 38.0.10
react: 16.12.0 => 16.12.0
react-dom: ^16.13.1 => 16.13.1
react-native: ~0.62.2 => 0.62.2
react-native-web: ^0.12.2 => 0.12.3
react-navigation: 4.0.10 => 4.0.10
npmGlobalPackages:
expo-cli: 3.27.14
Expo Workflow: bare

I already have metro.config.js file that contains the same exact code. but no images are shown(in IOS). Is there any other way?

initialize a new project with bare workflow, compare the result to yours. also, what sdk version are you using? if you are using sdk 38 and eject, you will end up on react-native 0.62.2, which does not include a patch from react-native 0.63 that fixes images on ios when built with xcode12 for ios 14. you can update or cherrypick that fix. if this is happening in debug mode for you then this is almost certainly the issue that you’re facing

@notbrent I have attempted updating to react-native 0.63 and expo 39 by hand and failed miserably. I saw numerous issues regarding expo 39 and do not want to try to upgrade just yet

What exactly do you refer to regarding

cherrypick that fix

Could that change be put into expo 38.0.11 somehow? or could you put explicit instructions on how to fix the xcode 12 issue?

please explain your situation. i do not have any context around your app. is it managed or bare?

Bare app. expo 38.

I recently updated my mac book to ios 14 with xcode 12. Images no longer load properly in my ios app. Android is fine.

You referred to this as a known fixed issue and it might be able to fix this issue without upgrading to expo 39.

@notbrent do you have the commit ID to cherry-pick?

yeah, sorry this is just a react-native problem and not specific to expo. you can see more info at https://github.com/facebook/react-native/issues/29279?_pjax=%23js-repo-pjax-container#issuecomment-658244428

here’s the upstream commit: https://github.com/facebook/react-native/commit/b6ded7261544c703e82e8dbfa442dad4b201d428

you can use patch-package to bring this in if you want

1 Like