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

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


当前回答

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

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

其他回答

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

也有这个问题。作为一个新手,我很天真地改变了启动屏幕。故事板到LaunchScreen.xib。运行失败了(呸),所以我把它改回。storyboard重新运行了应用程序,只是为了测试我没有搞砸任何其他事情——旧的屏幕没有首先出现。所以不管我做了什么,它一定把旧缓存冲出来了。

解决方案为我工作

从设备中删除应用程序 关闭设备 打开设备 清洁构建文件夹 再次构建、安装和启动应用程序。 享受

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

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

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