ChatGPT解决这个技术问题 Extra ChatGPT

iOS Keeping old launch screen and app icon after update

ios

I have an app where I recently replaced the launch images and app icons, I removed all of the old assets from everywhere in the project. When I upgrade the app from the old version to the new version by just building in Xcode, everything is fine. However, if I have the old version of my app installed then upgrade it from TestFlight, every time I kill the app then restart it the old launch image briefly appears before showing the new launch image. Similarly when I then close the app, the old app icon briefly flashes before switching back to my new one.

I opened up the App using iExplorer and noticed that there is an image of the old launch screen saved in the /Library/Caches/Shapshots directory (I don't know how or why it got there). When I delete it manually through iExplorer, it stops appearing. However, when I try to remove it with code using NSFileManager methods, I get errors saying I am forbidden from deleting files in this directory.

Has anyone experienced this before and have any advice?

Same problem, and with launch screens the new launch screen never shows, it is using the cached image of the previous version.

P
Preetam Jadakar

I have been able to reliably get the springboard cache cleared for testing launch image changes by doing this:

Delete your app from the device Power down the device Power up device, install and launch app.

The image updates properly every time. Shame I need to power down the device to get it to go - but at least I have been able to make progress this way. I hope this helps someone.

In case of the simulator, just restarting of simulator should work.


This is the only one solution that worked for me. Thank You very much!
Works for emulator too.
Is this also the fix for the TestFlight? updating the app from TestFlight also caches the launch images. are you sure this will not happen on the app version unlike the testflight?
this might be the stupitest bug i ve ever seen
I agree with @EFE. It's still happening in 2020. This fixes it but if all other icons can be updated without doing this, splash icon can too! WTF Apple?
M
Michal Šrůtek

These caches are used by Springboard to make app switching fast. This isn't a problem that will affect your production users and should in theory go away the next time Springboard decides to snapshot your app.

That being said, this isn't a problem you can fix. This is a bug in Apple's code not yours.

UPDATE: There appears to be a work around that doesn't require restarting the device.

This will take effect after the second launch!

do {
   try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
} catch {
   print("Failed to delete launch screen cache: \(error)")
}

A full explanation of how that works here: https://www.rambo.codes/posts/2019-12-09-clearing-your-apps-launch-screen-cache-on-ios


Can you please link to documentation that would confirm your statement "This isn't a problem that will affect your production users"? I have the exact same problem, I am OK if this is dev only but I won't take the chance without official documentation that clearly states what you say.
For some people am getting this for App Store update also :(.
Unfortunately I can confirm this problem affects even production users (so after upgrading the app from App Store).
Yes it does affect production builds/ App Store builds.
Any source for this?
M
Murray Sagal

For the simulator just Reset Contents and Settings...


This is not a question. The point is that when deploying a new app with new icons or images, they are not all refreshed the same way and some are kept on display while they have been removed.
J
JERC

This worked for me: http://arsenkin.com/launch_screen_image_cache.html

Again, thanks to the thread I have referenced above I found a way to solve this issue - name your new image differently from the one there was before in case your new one has the same name as the old one and put it out of the *.xcassets folder to the project directory and reference it in your UIImageView. And that's it. Sound stupid easy but oh gawd how much rage I had.


The key here is to keep those images out of the assets catalog. Thanks!
This solution really helps if you care about your production user's good UX and want to avoid that ugly transition between the old and the new image.
finally, A solution that actually works! The key here is to put the images out of the assets folder.
Works perfectly without restarting or deleting the app.
Weird. But the background image I moved out from the assets catalog sometimes is not loading and I get the black background. Now I need to debug it again, but I have no idea how to reproduce unfortunately.
Y
Yu-Sen Han

I found workaround solution what if you really want to fix this issue. Apple have some mechanisms to cache images of launch screen which indexing by image file name.

When you change any images on launch screen and you want to see those change in next run immediately. please using new image name which image you changed and link to new image file in storyboard or xib.

Run again, you will see new change appear.


I didn't want to delete the app so I tried this one. This plus restarting my device worked for me.
This didn't work for me. Restarting the devide also didn't work... I give up now.
Didn't work for me. I even removed the imageView and created a new one with the new image, and it still didn't work.
It didn't work for me. I got the old one image not loading (still background color was presented instead of an image) and it still was presented for a fraction of second before the new launch screen appeared.
A
Ankit Pundhir

Uninstall your app, restart your phone and install your app again... This actually fixed in my case.


What if this happens in Production? You can not expect every user to uninstall, restart the device.
C
Community

What worked for me:

Deleting the LaunchScreen's Scene and View Controller and create a new one (make sure you set it as "Initial View Controller" in the Attributes Inspector).

What did not work for me:

Deleting the app

Restarting the iPhone, Mac or Xcode

Deleting Derived Data

Deleting the device's container

Cleaning

Burning 3 Steve Jobs Voodoo dolls

Note:

Sometimes erasing (simulator) is needed too


I'm not convinced. I'm going to need source locations of the Steve Jobs voodoo dolls to confirm.
s
shim

I also faced the same issue. It happens because the simulator/ iOS device caches the launch image when you first launch the application. I added some modifications to Brian Trzupek's answer:

Delete the image set from Xcode assets (eg. launch_image) Add a new image set and add images to it. Switch off and switch on the iOS Device. (Reset Contents and Settings for simulator). Clean the Xcode build folder (Press command + option + shift + K). Delete the app from the device/simulator (if available). Run again.


h
hico

Honestly, I didn't take the risk to go live without being sure if this will be updated or not.

So, assuming you are using xcassets, a simple solution is:

Delete the old image set Recreate one with a different name and add your splash screen images Update your storyboard to use this 'new' image set reference

It will update for sure ! (I even tested with app already installed on the device). No need to clean cache of device or so.


佚名

Just connect your device, go to Xcode > Window > Devices > Your device, now in installed apps, select your app, right click and download container, go to the generated file, right click, Show package contents, AppData, Library, Caches, and delete files. Now go to Xcode > Window > Devices > Your device > your app and right click to replace containers.


S
Stephen Rauch

Delete your app from the device Power down the device Power up device Install and launch app.


M
M Murteza

Solution Work For Me

Delete your app from the device Switch off device Switch on device clean Build Folder Again build and install and launch app. Enjoy


a
ahbou

Xcode 10/iOS 12

After trying all the things mentioned above, I had to delete the imageview from the LaunchScreen and replace it with a new one.


position the image outside the asset folder and replace the imageview from the launch screen with a new one referenced to the image. This works for me !
Didn't work for me :/
S
Sorakris Chaladlamsakul

This worked for me: http://arsenkin.com/launch_screen_image_cache.html Again, thanks to the thread I have referenced above I found a way to solve this issue - name your new image differently from the one there was before in case your new one has the same name as the old one and put it out of the *.xcassets folder to the project directory and reference it in your UIImageView. And that's it. Sound stupid easy but oh gawd how much rage I had.

I can confirm that @JERC worked and thanks to arsenkin

In my case I work on a react native project and had a .storyboard file in ios/projectname I just want to replace the old image with the same size and keep the old constraints. I didn't want the user to delete the app or restart their phone.

WHAT I DID

Copy the image to the project src (in my case I put mine in src/assets). Open finder and drag the image to xcode project in to the project directory. There will be a popup make sure you create a reference to the project. here Change the image src in .storyboard to the referenced image. here Clean build folder. here Rebuild app


l
lramirez135

Ok, so I figured out the issue. In the previous version of my app, we were using a Launch Screen XIB. Somewhere in the development of this new version, the xib was deleted and replaced only with static launch images.

The solution is to use a Launch Screen XIB. I noticed that the moment I used a launch screen xib for the first time, the file stored in the snapshots directory was replaced with the snapshot of the xib.


Nope, I am using a Launch Screen XIB and it is not updating. I guess you workaround the problem by switching from Launch Screen > Static image > Launch Screen. Modifying the launch screen in XCode and running it still shows the old launch screen on the iPhone. The image is cached on the device. I guess if I change the name of the launch screen it will do the trick
Recreating a launch screen with a different name did not workaround the problem, still seeing the old one. The only "hope" is that iOS regenerates its cache at every app update, but I cannot find any documentation on this
W
Walter Monecke

This is the fastest way I found to resolve this issue although it sounds stupid:

Right click on LaunchScreen.xibor on your launchscreen file and select Remove file then select Remove to trash. This will remove all references of the file and its past updates from your project. Go into your trash and drag and drop the file back into your xCode project (within yourProjectName). Clean and rebuild.


M
Mor4eza

Use this piece of code to clean launch screen cache:

import UIKit

public extension UIApplication {
    func clearLaunchScreenCache() {
        #if DEBUG
        do {
            let launchScreenPath = "\(NSHomeDirectory())/Library/SplashBoard"
            try FileManager.default.removeItem(atPath: launchScreenPath)
        } catch {
            print("Failed to delete launch screen cache - \(error)")
        }
        #endif
    }
}

Usage:

UIApplication.shared.clearLaunchScreenCache()

j
jeff ayan

Make sure you did all these steps

Search for ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME key in build setting and search its assets value in entire application then remove it. Delete ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME from Build setting. Create New Launch screen Xcode -> File -> New -> File -> Launch Screen Goto App main Target -> General -> App Icons and Launch Images -> Launch Screen File -> Choose the New Launch Screen File. If you just changing the old Launch screen, try naming the new assets with different names.


S
SecretAgentMan

For Simulator Or For Real Device You just need to follow these steps.

remove you splash from xc assets. drag and drop png or jpg file into Root. LaunchScreen.xib or storyboard. open ViewController and set ImageView ref that particular image which you dragged.

If you don't have ViewController and using old version react you will just found there named as View. so remove that and make new ViewController in case if that View doesn't show your Splash.


r
richard s. hill

Had this problem also. Being a total novice I naively changed the LaunchScreen.storyboard to LaunchScreen.xib. The run failed (duh), so I changed it back to .storyboard re-ran the app just to test I'd not screwed anything else up - and the old screen didn't appear first. So whatever I did, it must have flushed out the old cache.


T
Tigran Iskandaryan

Try opening the simulator, going to Hardware -> Erase All Content and Settings.


A
Anton Filimonov

Had same problem but only with image used in launchscreen storyboard. Moving the image from the asset catalog changing its' name to the app bundle (for example, old image set in asset catalog was called launch_logo, and image in app bundle is called launchscreen_logo.png) solved the issue for us.


이혜린

I guess these are depended on situations. When It happens at debug or testing, works on deleting image on launch screen. Or uninstalling your apps, then restart launch.

But It goes even after archive, then It doesn't solve with reset and clean.


D
Denis Kreshikhin

Try it in AppDelegate

    if #available(iOS 13.0, *) {
        do {
            try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
        } catch {
            print("Failed to delete launch screen cache: \(error)")
        }
    } else {
        print("ios is min")
    }

t
timbru31

Inspired by Guilherme Rambo's blog entry, I've created a cordova-plugin to programmatically purge the launch screen cache on iOS 13+:

cordova.plugins.launchScreenCache.deleteLaunchScreenCache().finally((result) => {
    // returns true in the success case, false if iOS <13
    // rejects in an error case
});

More information can be found on the GitHub repo


M
MilanPanchal

In my case, I haven't selected App Icons Source From App Setting -> General -> App Icons and Launch Images -> App Icons Source

https://i.stack.imgur.com/IyHsr.png


M
Moustaoui Salaheddine

First of all

Clean & Build project

Method 1: Rename the Splash image loaded in LaunchScreen.storyboard.

For example, I loaded "splash" but changed it to "splashNew".

Method 2:

Run your app on a different device or emulator

For example, if you run app in a emulator iphone 11 run it into iphone 12