Fix the cached launch screen image bug on iOS
Every once in a while you’ll probably make some changes to your launch screen, and I’ve run into a few headaches while doing it. Most recently I had trouble with an image not updating as expected. Let’s walk through what I did, what the problem was, and how to fix it.
Here’s my launch screen storyboard
And here’s my asset file
When the app runs, we see this just as expected
Now let’s go update that image asset, because I feel like a 3D image will be much cooler
Our launch screen file updates in Xcode as expected
Now let’s build and run, to see our cool new launch screen
Hold on a second…
What’s the deal? It turns out iOS caches lots of stuff in order to improve performance, save power, etc. Additionally, there is a bug as of iOS 14 with caching of .xcassets files. To get around this, let’s drop our new image straight into the app directory rather than into an asset file.
Now we need to update our launch screen image so it displays the new image (Xcode recognizes our image file in the project folder, so we just have to select the new app logo file in the right sidebar)
And finally let’s build and run one more time
There we go! It looks as expected with no device reboot needed to fix the cache. This fix can be critical when you’re working on an enterprise level app & company branding has changed - you definitely don’t want old images sticking around in the launch screen for millions of users. That would be embarrassing.
I hope this article helps you out! Happy coding & I’ll see you next time.
App Logo Attribution: