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

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


当前回答

在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")
    }

其他回答

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

好吧,我找到问题所在了。在我之前的应用版本中,我们使用的是启动屏幕XIB。在这个新版本的开发过程中,xib被删除了,取而代之的是静态启动图像。

解决方案是使用启动屏幕XIB。我注意到,当我第一次使用启动屏幕xib时,存储在快照目录中的文件被xib的快照所取代。

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

只要连接你的设备,进入Xcode >窗口>设备>你的设备, 现在在安装的应用程序中,选择你的应用程序,右键单击并下载容器,转到生成的文件,右键单击,显示包内容,AppData,库,缓存,并删除文件。 现在转到Xcode >窗口>设备>你的设备>你的应用,右键点击替换容器。

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