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方法用代码删除它时,我得到错误,说我被禁止删除这个目录中的文件。

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


当前回答

我找到了变通方案,如果你真的想解决这个问题。 苹果公司有一些机制来缓存启动屏幕的图像,通过图像文件名进行索引。

当你改变任何图像在启动屏幕上,你想看到这些变化在下次运行立即。请使用你修改过的新图片名称,并链接到storyboard或xib中的新图片文件。

再次运行,您将看到新的更改出现。

其他回答

确保你完成了所有这些步骤

在build中搜索ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME键 然后在整个应用程序中设置和搜索其资产值 删除它。 从构建设置中删除ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME。 创建新的启动屏幕Xcode ->文件->新建->文件->启动 屏幕 Goto应用程序主目标->一般->应用程序图标和启动图像-> 选择新的启动屏幕文件。 如果你只是改变旧的启动屏幕,试着命名新的资产 名字不同。

对于模拟器,只需重置内容和设置…

我已经能够通过这样做可靠地获得跳板缓存清除测试发射图像更改:

从设备中删除应用程序 设备下电 电源设备,安装和启动应用程序。

图像每次都能正确更新。很遗憾,我需要关掉设备才能让它运行,但至少我已经能够通过这种方式取得进展。

在模拟器的情况下,只是重新启动模拟器应该工作。

卸载你的应用程序,重启你的手机,重新安装你的应用程序…这在我的例子中是固定的。

使用这段代码清理启动屏幕缓存:

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
    }
}

用法:

UIApplication.shared.clearLaunchScreenCache()