Skip to content

Commit dff2d94

Browse files
authored
Merge pull request #14 from CRKatri/ck/uicache-/p/p/p/-support
/p/p/p/Applications support and App Store warning
2 parents f2d5d54 + 56c770b commit dff2d94

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ MAN := gssc.1 ldrestart.1 sbdidlaunch.1 sbreload.1 uicache.1 uiopen.1 deviceinfo
1111
ALLMAC := gssc deviceinfo
1212
MANMAC := gssc.1 deviceinfo.1
1313

14+
APP_PATH ?= $(MEMO_PREFIX)/Applications
15+
1416
sign: $(ALL)
1517
$(STRIP) $(ALL)
1618
$(LDID) -Sent.plist ldrestart sbdidlaunch deviceinfo
@@ -34,7 +36,7 @@ sbreload: sbreload.m sbreload-launchd.c sbreload.plist
3436
$(CC) -fobjc-arc -O3 $(CFLAGS) sbreload.m sbreload-launchd.c -o sbreload $(LDFLAGS) -framework Foundation
3537

3638
uicache: uicache.m uicache.plist
37-
$(CC) -fobjc-arc -O3 $(CFLAGS) uicache.m -o uicache -framework Foundation $(LDFLAGS) -framework MobileCoreServices
39+
$(CC) -fobjc-arc -O3 $(CFLAGS) uicache.m -o uicache -framework Foundation $(LDFLAGS) -framework MobileCoreServices -DAPP_PATH="@\"$(APP_PATH)\""
3840

3941
uiopen: uiopen.m ent.plist
4042
$(CC) -fobjc-arc -O3 $(CFLAGS) uiopen.m -o uiopen $(LDFLAGS) -framework Foundation -framework MobileCoreServices

uicache.1

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ rather than just the changes.
3131
This option will make
3232
.Fl a
3333
significantly slower.
34+
When used with
35+
.Fl p
36+
or
37+
.Fl u ,
38+
.Nm
39+
will operate on apps installed from the App Store.
3440
.It Fl h , -help
3541
Prints a help text
3642
.It Fl r , -respring
@@ -74,3 +80,9 @@ and
7480
.Fl i
7581
flags were added to uikittools-ng on April 4, 2021, by
7682
.An Cameron Katri .
83+
.Sh CAVEATS
84+
The
85+
.Nm
86+
utility does not work on any applications that were installed from the App Store.
87+
There is a check to prevent any modifications to them which will be overwritten by
88+
.Fl f .

uicache.m

+32-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#import <MobileCoreServices/MobileCoreServices.h>
77
#import <Foundation/NSURL.h>
88

9+
#ifndef APP_PATH
10+
#define APP_PATH @"/private/preboot/procursus/Applications
11+
#endif
12+
913
@interface _LSApplicationState : NSObject
1014
-(BOOL)isValid;
1115
@end
@@ -79,10 +83,11 @@ void help(char *name) {
7983
" -a, --all Update all system and internal applications\n"
8084
" (replicates the old uicache behavior)\n"
8185
" -f, --force Force -a to reregister all Applications\n"
86+
" and modify App Store apps\n"
8287
" -p, --path <path> Update application bundle at the specified path\n"
8388
" -u, --unregister <path> Unregister application bundle at the specified path\n"
8489
" -r, --respring Restart SpringBoard and backboardd after\n"
85-
" updating applications.\n"
90+
" updating applications\n"
8691
" -l, --list List the bundle ids of installed apps\n"
8792
" -i, --info <bundleid> Give information about given bundle id\n"
8893
" -h, --help Give this help list.\n\n"
@@ -98,6 +103,15 @@ void registerPath(char *path, int unregister) {
98103
LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:[NSString stringWithUTF8String:path]];
99104
path = (char *)[[app bundleURL] fileSystemRepresentation];
100105
}
106+
107+
if ([[NSString stringWithUTF8String:path] hasPrefix:@"/private/var/containers/Bundle/Application"] || [[NSString stringWithUTF8String:path] hasPrefix:@"/var/containers/Bundle/Application"]) {
108+
printf("uicache does not support App Store apps.\n");
109+
if (force)
110+
printf("Continuing anyway...\n");
111+
else
112+
return;
113+
}
114+
101115
NSString *rawPath = [NSString stringWithUTF8String:path];
102116
rawPath = [rawPath stringByResolvingSymlinksInPath];
103117

@@ -210,6 +224,7 @@ void registerAll() {
210224
}
211225

212226
NSArray<NSString *> *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/Applications" error:nil];
227+
NSArray<NSString *> *filesSecondary = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:APP_PATH error:nil];
213228

214229
NSMutableSet<NSString*> *installed = [[NSMutableSet alloc] init];
215230

@@ -228,11 +243,26 @@ void registerAll() {
228243
}
229244
}
230245

246+
for (NSString *file in filesSecondary) {
247+
if ([file hasSuffix:@".app"] &&
248+
[[NSFileManager defaultManager]
249+
fileExistsAtPath:[NSString
250+
stringWithFormat:@"%@/%@/Info.plist", APP_PATH, file]] &&
251+
[[NSFileManager defaultManager]
252+
fileExistsAtPath:[NSString stringWithFormat:@"%@/%@/%@",
253+
APP_PATH, file, [[NSDictionary dictionaryWithContentsOfURL:[NSURL
254+
fileURLWithPath:[NSString stringWithFormat:@"%@/%@/Info.plist", APP_PATH, file]] error:nil]
255+
valueForKey:@"CFBundleExecutable"]]])
256+
{
257+
[installed addObject:[NSString stringWithFormat:@"%@/%@", APP_PATH, file]];
258+
}
259+
}
260+
231261
NSMutableSet<NSString*> *registered = [[NSMutableSet alloc] init];
232262

233263
LSApplicationWorkspace *workspace = [LSApplicationWorkspace defaultWorkspace];
234264
for (LSApplicationProxy *app in [workspace allApplications]) {
235-
if ([[NSString stringWithUTF8String:[[app bundleURL] fileSystemRepresentation]] hasPrefix:@"/Applications"]) {
265+
if ([[NSString stringWithUTF8String:[[app bundleURL] fileSystemRepresentation]] hasPrefix:@"/Applications"] || [[NSString stringWithUTF8String:[[app bundleURL] fileSystemRepresentation]] hasPrefix:APP_PATH]) {
236266
[registered addObject:[NSString stringWithUTF8String:[[app bundleURL] fileSystemRepresentation]]];
237267
}
238268
}

0 commit comments

Comments
 (0)