iPhone 12 iOS 16.3.1 执行一直不成功
ll_getLaunchImagePath 方法返回一直为空 DEBUG发现 [NSFileManager.defaultManager fileExistsAtPath:path] 校验一直为false 路径打印出来为 "/var/mobile/Containers/Data/Application/xxx/Library/SplashBoard/Snapshots/xxx - {DEFAULT GROUP}", 对比Demo中打印路径也基本一致,但是就是校验false
系统配置有多个target,对应多种语言
可以提供一下示例demo吗?或者你新建一个项目;我在真机16.4.1上面测试并没有复现你的问题。
我跑你的Demo没问题,在我自己的App上就不行 `+ (nullable NSString *)ll_getLaunchImagePath { static NSString *path = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSString *bundleIdentifier = NSBundle.mainBundle.bundleIdentifier;
if (@available(iOS 13.0, *)) {
NSString *libraryPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES).firstObject;
path = [NSString pathWithComponents:@[libraryPath, @"SplashBoard", @"Snapshots", [NSString stringWithFormat:@"%@ - {DEFAULT GROUP}", bundleIdentifier]]];
} else {
NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
path = [NSString pathWithComponents:@[cachePath, @"Snapshots", bundleIdentifier]];
}
NSLog(@"path = %@",path);
path = [NSFileManager.defaultManager fileExistsAtPath:path] ? path : nil;
});
return path;
}`; 这个方法返回path为nil
解决了,我代码早些时候添加了清理启动图的功能,一直没去掉,在debug的时候调用了
[NSFileManager.defaultManager removeItemAtPath:[NSString stringWithFormat:@"%@/Library/SplashBoard",NSHomeDirectory()] error:&clearLaunchrror],
所以导致后面再去查询系统的启动图为空;感谢