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.

我使用iExplorer打开应用,并注意到/Library/Caches/Shapshots目录中保存了旧的启动屏幕图像(我不知道它是如何或为什么会出现在那里)。当我通过iExplorer手动删除它时,它就不再出现了。但是,当我尝试使用NSFileManager方法用代码删除它时,我得到错误,说我被禁止删除这个目录中的文件。

有人有过这样的经历吗?有什么建议吗?


当前回答

受到Guilherme Rambo博客文章的启发,我创建了一个cordova插件,以编程方式清除iOS 13+上的启动屏幕缓存:

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

更多信息可以在GitHub回购上找到

其他回答

有同样的问题,但只是在启动屏幕故事板使用的图像。将图像从资产目录中移动,并将其名称更改为应用程序包(例如,资产目录中设置的旧图像称为launch_logo,应用程序包中的图像称为launchscreen_logo.png)解决了我们的问题。

老实说,我没有冒险在不确定是否会更新的情况下上线。

所以,假设你正在使用xcassets,一个简单的解决方案是:

删除旧映像集 重新创建一个不同的名称,并添加您的启动画面图像 更新你的故事板以使用这个“新”图像集引用

它肯定会更新!(我甚至在设备上已经安装了应用程序的情况下进行测试)。不需要清理缓存的设备左右。

Springboard使用这些缓存来快速切换应用程序。这个问题不会影响到你的产品用户,理论上,下次Springboard决定对你的应用进行快照时,这个问题就会消失。

也就是说,这不是一个你能解决的问题。这是苹果代码中的bug,不是你的。

更新: 似乎有一个不需要重新启动设备的解决方案。

这将在第二次发射后生效!

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

关于它是如何工作的完整解释:https://www.rambo.codes/posts/2019-12-09-clearing-your-apps-launch-screen-cache-on-ios

尝试打开模拟器,进入硬件->擦除所有内容和设置。

我也面临着同样的问题。这是因为模拟器/ iOS设备在你第一次启动应用程序时缓存了启动图像。我对Brian Trzupek的回答做了一些修改:

删除图像集从Xcode资产(例如。launch_image) 添加一个新的图像集,并向其添加图像。 关闭并打开iOS设备。(重置模拟器的内容和设置)。 清除Xcode构建文件夹(按command + option + shift + K)。 从设备/模拟器中删除应用(如果可用)。 再次运行。