|
24 | 24 | int unknown2;
|
25 | 25 | };
|
26 | 26 |
|
27 |
| -static NSString *systemLibraryPath() |
| 27 | +static NSString *systemRoot() |
28 | 28 | {
|
29 |
| - static NSString *systemLibraryPath = nil; |
30 |
| - if (systemLibraryPath) |
31 |
| - return systemLibraryPath; |
| 29 | + static NSString *systemRoot = nil; |
| 30 | + if (systemRoot) |
| 31 | + return systemRoot; |
32 | 32 |
|
33 | 33 | // Extract images from actual firmware if mounted instead of simulator
|
34 | 34 | // Use https://github.com/kennytm/Miscellaneous/blob/master/ipsw_decrypt.py
|
|
46 | 46 | NSString *model = [wallpapers count] == 1 ? [wallpapers lastObject] : @"iPhone";
|
47 | 47 | if ([[UIDevice currentDevice].model hasPrefix:model])
|
48 | 48 | {
|
49 |
| - systemLibraryPath = [volumePath retain]; |
50 |
| - return systemLibraryPath; |
| 49 | + systemRoot = [volumePath retain]; |
| 50 | + return systemRoot; |
51 | 51 | }
|
52 | 52 | }
|
53 | 53 | }
|
54 | 54 |
|
55 |
| - NSString *systemFrameworksPath = @"/System/Library/Frameworks"; |
56 |
| - for (NSBundle *framework in [NSBundle allFrameworks]) |
57 |
| - { |
58 |
| - // So that it works on both simulator and device |
59 |
| - NSString *frameworkName = [[framework bundlePath] lastPathComponent]; |
60 |
| - if ([frameworkName isEqualToString:@"Foundation.framework"]) |
61 |
| - { |
62 |
| - systemFrameworksPath = [[framework bundlePath] stringByDeletingLastPathComponent]; |
63 |
| - break; |
64 |
| - } |
65 |
| - } |
66 |
| - |
67 |
| - systemLibraryPath = [[systemFrameworksPath stringByDeletingLastPathComponent] retain]; |
68 |
| - return systemLibraryPath; |
| 55 | + return [[[NSProcessInfo processInfo] environment] objectForKey:@"IPHONE_SIMULATOR_ROOT"] ?: @"/"; |
69 | 56 | }
|
70 | 57 |
|
71 | 58 | static NSString *pathWithScale(NSString *path, CGFloat scale)
|
@@ -427,18 +414,18 @@ - (void) loadImages
|
427 | 414 |
|
428 | 415 | if ([self isArtwork])
|
429 | 416 | {
|
430 |
| - for (NSString *relativePath in [[NSFileManager defaultManager] enumeratorAtPath:systemLibraryPath()]) |
| 417 | + for (NSString *relativePath in [[NSFileManager defaultManager] enumeratorAtPath:systemRoot()]) |
431 | 418 | {
|
432 | 419 | BOOL scale1 = [UIScreen mainScreen].scale == 1 && [[relativePath lowercaseString] rangeOfString:@"@2x"].location == NSNotFound;
|
433 | 420 | BOOL scale2 = [UIScreen mainScreen].scale == 2 && [[relativePath lowercaseString] rangeOfString:@"@2x"].location != NSNotFound;
|
434 | 421 | if ([relativePath hasSuffix:@"png"] && (scale1 || scale2))
|
435 | 422 | {
|
436 |
| - NSString *filePath = [systemLibraryPath() stringByAppendingPathComponent:relativePath]; |
| 423 | + NSString *filePath = [systemRoot() stringByAppendingPathComponent:relativePath]; |
437 | 424 | [self addImage:imageWithContentsOfFile(filePath) filePath:filePath];
|
438 | 425 | }
|
439 | 426 | else if ([[relativePath pathExtension] isEqualToString:@"artwork"])
|
440 | 427 | {
|
441 |
| - NSString *artworkPath = [systemLibraryPath() stringByAppendingPathComponent:relativePath]; |
| 428 | + NSString *artworkPath = [systemRoot() stringByAppendingPathComponent:relativePath]; |
442 | 429 | NSBundle *bundle = [NSBundle bundleWithPath:[artworkPath stringByDeletingLastPathComponent]];
|
443 | 430 | NSString *artworkName = [[relativePath lastPathComponent] stringByDeletingPathExtension];
|
444 | 431 | NSRange atRange = [artworkName rangeOfString:@"@"];
|
|
0 commit comments