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

其他回答

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

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

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

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

这个对我很有用:http://arsenkin.com/launch_screen_image_cache.html

再一次,感谢我上面提到的帖子,我找到了一种方法 解决这个问题-命名你的新图像不同于那里的一个 以防你的新名字和旧名字一样 把它从*里拿出来。Xcassets文件夹到项目目录和 在UIImageView中引用它。就是这样。听起来很傻很简单 天啊,我有多愤怒。

解决方案为我工作

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

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

对我有用的是:

删除启动屏幕的场景和视图控制器,并创建一个新的(确保你在属性检查器中将其设置为“初始视图控制器”)。

什么对我不起作用:

删除应用 重新启动iPhone、Mac或Xcode 删除派生数据 删除设备的容器 清洁 焚烧3个史蒂夫·乔布斯的巫毒娃娃

注意:

有时也需要擦除(模拟器)