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?
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.
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
For the simulator just Reset Contents and Settings...
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 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.
Uninstall your app, restart your phone and install your app again... This actually fixed in my case.
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 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.
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.
Delete your app from the device Power down the device Power up device Install and launch app.
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
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.
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
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.
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.
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()
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.
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.
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.
Try opening the simulator, going to Hardware -> Erase All Content and Settings.
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.
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")
}
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
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
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
Success story sharing