mirror of
https://github.com/opa334/TrollStore.git
synced 2026-07-02 11:17:51 +08:00
Readd ldid for use on iOS 14
This commit is contained in:
@@ -191,6 +191,7 @@
|
||||
<key>TSRootBinaries</key>
|
||||
<array>
|
||||
<string>trollstorehelper</string>
|
||||
<string>ldid</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -47,11 +47,20 @@ extern NSUserDefaults* trollStoreUserDefaults();
|
||||
case 172:
|
||||
errorDescription = @"The app does not contain an Info.plist file.";
|
||||
break;
|
||||
case 173:
|
||||
errorDescription = @"The app is not signed with a fake CoreTrust certificate and ldid is not installed. Install ldid in the settings tab and try again.";
|
||||
break;
|
||||
case 174:
|
||||
errorDescription = @"The app's main executable does not exist.";
|
||||
break;
|
||||
case 175:
|
||||
errorDescription = @"Failed to sign the app.";
|
||||
case 175: {
|
||||
if (@available(iOS 15, *)) {
|
||||
errorDescription = @"Failed to sign the app.";
|
||||
}
|
||||
else {
|
||||
errorDescription = @"Failed to sign the app. ldid returned a non zero status code.";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 176:
|
||||
errorDescription = @"The app's Info.plist is missing required values.";
|
||||
|
||||
@@ -9,4 +9,6 @@
|
||||
|
||||
+ (void)handleAppInstallFromRemoteURL:(NSURL*)remoteURL completion:(void (^)(BOOL, NSError*))completion;
|
||||
|
||||
+ (void)installLdid;
|
||||
|
||||
@end
|
||||
@@ -187,4 +187,48 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)installLdid
|
||||
{
|
||||
fetchLatestLdidVersion(^(NSString* latestVersion)
|
||||
{
|
||||
if(!latestVersion) return;
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
NSURL* ldidURL = [NSURL URLWithString:@"https://github.com/opa334/ldid/releases/latest/download/ldid"];
|
||||
NSURLRequest* ldidRequest = [NSURLRequest requestWithURL:ldidURL];
|
||||
|
||||
[TSPresentationDelegate startActivity:@"Installing ldid"];
|
||||
|
||||
NSURLSessionDownloadTask* downloadTask = [NSURLSession.sharedSession downloadTaskWithRequest:ldidRequest completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error)
|
||||
{
|
||||
if(error)
|
||||
{
|
||||
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:@"Error" message:[NSString stringWithFormat:@"Error downloading ldid: %@", error] preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
|
||||
[errorAlert addAction:closeAction];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[TSPresentationDelegate stopActivityWithCompletion:^
|
||||
{
|
||||
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
|
||||
}];
|
||||
});
|
||||
}
|
||||
else if(location)
|
||||
{
|
||||
spawnRoot(rootHelperPath(), @[@"install-ldid", location.path, latestVersion], nil, nil);
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[TSPresentationDelegate stopActivityWithCompletion:nil];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"TrollStoreReloadSettingsNotification" object:nil userInfo:nil];
|
||||
});
|
||||
}
|
||||
}];
|
||||
|
||||
[downloadTask resume];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -72,6 +72,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
// We want to auto install ldid if either it doesn't exist
|
||||
// or if it's the one from an old TrollStore version that's no longer supported
|
||||
- (void)handleLdidCheck
|
||||
{
|
||||
if (@available(iOS 15, *)) {} else {
|
||||
NSString* tsAppPath = [NSBundle mainBundle].bundlePath;
|
||||
|
||||
NSString* ldidPath = [tsAppPath stringByAppendingPathComponent:@"ldid"];
|
||||
NSString* ldidVersionPath = [tsAppPath stringByAppendingPathComponent:@"ldid.version"];
|
||||
|
||||
if(![[NSFileManager defaultManager] fileExistsAtPath:ldidPath] || ![[NSFileManager defaultManager] fileExistsAtPath:ldidVersionPath])
|
||||
{
|
||||
[TSInstallationController installLdid];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
@@ -87,6 +104,10 @@
|
||||
{
|
||||
[self handleURLContexts:connectionOptions.URLContexts scene:(UIWindowScene*)scene];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self handleLdidCheck];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
{
|
||||
PSSpecifier* _installPersistenceHelperSpecifier;
|
||||
NSString* _newerVersion;
|
||||
NSString* _newerLdidVersion;
|
||||
}
|
||||
@end
|
||||
@@ -33,6 +33,28 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (@available(iOS 15, *)) {} else {
|
||||
fetchLatestLdidVersion(^(NSString* latestVersion)
|
||||
{
|
||||
NSString* ldidVersionPath = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"ldid.version"];
|
||||
NSString* ldidVersion = nil;
|
||||
NSData* ldidVersionData = [NSData dataWithContentsOfFile:ldidVersionPath];
|
||||
if(ldidVersionData)
|
||||
{
|
||||
ldidVersion = [[NSString alloc] initWithData:ldidVersionData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
if(![latestVersion isEqualToString:ldidVersion])
|
||||
{
|
||||
_newerLdidVersion = latestVersion;
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self reloadSpecifiers];
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableArray*)specifiers
|
||||
@@ -91,6 +113,84 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
||||
|
||||
[_specifiers addObject:rebuildIconCacheSpecifier];
|
||||
|
||||
if (@available(iOS 15, *)) { }
|
||||
else {
|
||||
NSString* ldidPath = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"ldid"];
|
||||
NSString* ldidVersionPath = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"ldid.version"];
|
||||
BOOL ldidInstalled = [[NSFileManager defaultManager] fileExistsAtPath:ldidPath];
|
||||
|
||||
NSString* ldidVersion = nil;
|
||||
NSData* ldidVersionData = [NSData dataWithContentsOfFile:ldidVersionPath];
|
||||
if(ldidVersionData)
|
||||
{
|
||||
ldidVersion = [[NSString alloc] initWithData:ldidVersionData encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
PSSpecifier* signingGroupSpecifier = [PSSpecifier emptyGroupSpecifier];
|
||||
signingGroupSpecifier.name = @"Signing";
|
||||
|
||||
if(ldidInstalled)
|
||||
{
|
||||
[signingGroupSpecifier setProperty:@"ldid is installed and allows TrollStore to install unsigned IPA files." forKey:@"footerText"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[signingGroupSpecifier setProperty:@"In order for TrollStore to be able to install unsigned IPAs, ldid has to be installed using this button. It can't be directly included in TrollStore because of licensing issues." forKey:@"footerText"];
|
||||
}
|
||||
|
||||
[_specifiers addObject:signingGroupSpecifier];
|
||||
|
||||
if(ldidInstalled)
|
||||
{
|
||||
NSString* installedTitle = @"ldid: Installed";
|
||||
if(ldidVersion)
|
||||
{
|
||||
installedTitle = [NSString stringWithFormat:@"%@ (%@)", installedTitle, ldidVersion];
|
||||
}
|
||||
|
||||
PSSpecifier* ldidInstalledSpecifier = [PSSpecifier preferenceSpecifierNamed:installedTitle
|
||||
target:self
|
||||
set:nil
|
||||
get:nil
|
||||
detail:nil
|
||||
cell:PSStaticTextCell
|
||||
edit:nil];
|
||||
[ldidInstalledSpecifier setProperty:@NO forKey:@"enabled"];
|
||||
ldidInstalledSpecifier.identifier = @"ldidInstalled";
|
||||
[_specifiers addObject:ldidInstalledSpecifier];
|
||||
|
||||
if(_newerLdidVersion && ![_newerLdidVersion isEqualToString:ldidVersion])
|
||||
{
|
||||
NSString* updateTitle = [NSString stringWithFormat:@"Update to %@", _newerLdidVersion];
|
||||
PSSpecifier* ldidUpdateSpecifier = [PSSpecifier preferenceSpecifierNamed:updateTitle
|
||||
target:self
|
||||
set:nil
|
||||
get:nil
|
||||
detail:nil
|
||||
cell:PSButtonCell
|
||||
edit:nil];
|
||||
ldidUpdateSpecifier.identifier = @"updateLdid";
|
||||
[ldidUpdateSpecifier setProperty:@YES forKey:@"enabled"];
|
||||
ldidUpdateSpecifier.buttonAction = @selector(installOrUpdateLdidPressed);
|
||||
[_specifiers addObject:ldidUpdateSpecifier];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PSSpecifier* installLdidSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Install ldid"
|
||||
target:self
|
||||
set:nil
|
||||
get:nil
|
||||
detail:nil
|
||||
cell:PSButtonCell
|
||||
edit:nil];
|
||||
installLdidSpecifier.identifier = @"installLdid";
|
||||
[installLdidSpecifier setProperty:@YES forKey:@"enabled"];
|
||||
installLdidSpecifier.buttonAction = @selector(installOrUpdateLdidPressed);
|
||||
[_specifiers addObject:installLdidSpecifier];
|
||||
}
|
||||
}
|
||||
|
||||
PSSpecifier* persistenceGroupSpecifier = [PSSpecifier emptyGroupSpecifier];
|
||||
persistenceGroupSpecifier.name = @"Persistence";
|
||||
[_specifiers addObject:persistenceGroupSpecifier];
|
||||
@@ -265,6 +365,11 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
||||
respring();
|
||||
}
|
||||
|
||||
- (void)installOrUpdateLdidPressed
|
||||
{
|
||||
[TSInstallationController installLdid];
|
||||
}
|
||||
|
||||
- (void)installPersistenceHelperPressed
|
||||
{
|
||||
NSMutableArray* appCandidates = [NSMutableArray new];
|
||||
|
||||
Reference in New Issue
Block a user