mirror of
				https://github.com/opa334/TrollStore.git
				synced 2025-11-04 07:32:36 +08:00 
			
		
		
		
	Update uicache.m
This commit is contained in:
		
							parent
							
								
									00887a9145
								
							
						
					
					
						commit
						f912627f1c
					
				@ -82,173 +82,194 @@ NSDictionary *constructEnvironmentVariablesForContainerPath(NSString *containerP
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool registerPath(NSString *path, BOOL unregister, BOOL forceSystem) {
 | 
			
		||||
	if (!path) return false;
 | 
			
		||||
    if (!path) return false;
 | 
			
		||||
 | 
			
		||||
	LSApplicationWorkspace *workspace = [LSApplicationWorkspace defaultWorkspace];
 | 
			
		||||
	if (unregister && ![[NSFileManager defaultManager] fileExistsAtPath:path]) {
 | 
			
		||||
		LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:path];
 | 
			
		||||
		if (app.bundleURL) {
 | 
			
		||||
			path = [app bundleURL].path;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
    LSApplicationWorkspace *workspace = [LSApplicationWorkspace defaultWorkspace];
 | 
			
		||||
 | 
			
		||||
	path = path.stringByResolvingSymlinksInPath.stringByStandardizingPath;
 | 
			
		||||
    // Adjust path if unregistering and the app doesn't exist at the provided path
 | 
			
		||||
    if (unregister && ![[NSFileManager defaultManager] fileExistsAtPath:path]) {
 | 
			
		||||
        LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:path];
 | 
			
		||||
        if (app.bundleURL) {
 | 
			
		||||
            path = app.bundleURL.path;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	NSDictionary *appInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[path stringByAppendingPathComponent:@"Info.plist"]];
 | 
			
		||||
	NSString *appBundleID = [appInfoPlist objectForKey:@"CFBundleIdentifier"];
 | 
			
		||||
    // Resolve path, resolve symlinks, and standardize
 | 
			
		||||
    path = path.stringByResolvingSymlinksInPath.stringByStandardizingPath;
 | 
			
		||||
 | 
			
		||||
	if([immutableAppBundleIdentifiers() containsObject:appBundleID.lowercaseString]) return false;
 | 
			
		||||
    NSDictionary *appInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[path stringByAppendingPathComponent:@"Info.plist"]];
 | 
			
		||||
    NSString *appBundleID = [appInfoPlist objectForKey:@"CFBundleIdentifier"];
 | 
			
		||||
 | 
			
		||||
	if (appBundleID && !unregister) {
 | 
			
		||||
		NSString *appExecutablePath = [path stringByAppendingPathComponent:appInfoPlist[@"CFBundleExecutable"]];
 | 
			
		||||
		NSDictionary *entitlements = dumpEntitlementsFromBinaryAtPath(appExecutablePath);
 | 
			
		||||
    if([immutableAppBundleIdentifiers() containsObject:appBundleID.lowercaseString]) {
 | 
			
		||||
        // Application is immutable, do not proceed with registration
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		NSString *appDataContainerID = appBundleID;
 | 
			
		||||
		BOOL appContainerized = constructContainerizationForEntitlements(entitlements, &appDataContainerID);
 | 
			
		||||
    if (appBundleID && !unregister) {
 | 
			
		||||
        NSString *appExecutablePath = [path stringByAppendingPathComponent:appInfoPlist[@"CFBundleExecutable"]];
 | 
			
		||||
        NSDictionary *entitlements = dumpEntitlementsFromBinaryAtPath(appExecutablePath);
 | 
			
		||||
 | 
			
		||||
		MCMContainer *appDataContainer = [NSClassFromString(@"MCMAppDataContainer") containerWithIdentifier:appDataContainerID createIfNecessary:YES existed:nil error:nil];
 | 
			
		||||
		NSString *containerPath = [appDataContainer url].path;
 | 
			
		||||
        NSString *appDataContainerID = appBundleID;
 | 
			
		||||
        BOOL appContainerized = constructContainerizationForEntitlements(entitlements, &appDataContainerID);
 | 
			
		||||
 | 
			
		||||
		BOOL isRemovableSystemApp = [[NSFileManager defaultManager] fileExistsAtPath:[@"/System/Library/AppSignatures" stringByAppendingPathComponent:appBundleID]];
 | 
			
		||||
		BOOL registerAsUser = [path hasPrefix:@"/var/containers"] && !isRemovableSystemApp && !forceSystem;
 | 
			
		||||
        MCMContainer *appDataContainer = [NSClassFromString(@"MCMAppDataContainer") containerWithIdentifier:appDataContainerID createIfNecessary:YES existed:nil error:nil];
 | 
			
		||||
        NSString *containerPath = [appDataContainer url].path;
 | 
			
		||||
 | 
			
		||||
		NSMutableDictionary *dictToRegister = [NSMutableDictionary dictionary];
 | 
			
		||||
        BOOL isRemovableSystemApp = [[NSFileManager defaultManager] fileExistsAtPath:[@"/System/Library/AppSignatures" stringByAppendingPathComponent:appBundleID]];
 | 
			
		||||
        BOOL registerAsUser = [path hasPrefix:@"/var/containers"] && !isRemovableSystemApp && !forceSystem;
 | 
			
		||||
 | 
			
		||||
		// Add entitlements
 | 
			
		||||
        NSMutableDictionary *dictToRegister = [NSMutableDictionary dictionary];
 | 
			
		||||
 | 
			
		||||
		if (entitlements) {
 | 
			
		||||
			dictToRegister[@"Entitlements"] = entitlements;
 | 
			
		||||
		}
 | 
			
		||||
        // Add entitlements to the dictionary
 | 
			
		||||
        if (entitlements) {
 | 
			
		||||
            dictToRegister[@"Entitlements"] = entitlements;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		// Misc
 | 
			
		||||
        // Miscellaneous registration information
 | 
			
		||||
        dictToRegister[@"ApplicationType"] = registerAsUser ? @"User" : @"System";
 | 
			
		||||
        dictToRegister[@"CFBundleIdentifier"] = appBundleID;
 | 
			
		||||
        dictToRegister[@"CodeInfoIdentifier"] = appBundleID;
 | 
			
		||||
        dictToRegister[@"CompatibilityState"] = @0;
 | 
			
		||||
        dictToRegister[@"IsContainerized"] = @(appContainerized);
 | 
			
		||||
 | 
			
		||||
		dictToRegister[@"ApplicationType"] = registerAsUser ? @"User" : @"System";
 | 
			
		||||
		dictToRegister[@"CFBundleIdentifier"] = appBundleID;
 | 
			
		||||
		dictToRegister[@"CodeInfoIdentifier"] = appBundleID;
 | 
			
		||||
		dictToRegister[@"CompatibilityState"] = @0;
 | 
			
		||||
		dictToRegister[@"IsContainerized"] = @(appContainerized);
 | 
			
		||||
		if (containerPath) {
 | 
			
		||||
			dictToRegister[@"Container"] = containerPath;
 | 
			
		||||
			dictToRegister[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(containerPath, appContainerized);
 | 
			
		||||
		}
 | 
			
		||||
		dictToRegister[@"IsDeletable"] = @(![appBundleID isEqualToString:@"com.opa334.TrollStore"] && kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_15_0);
 | 
			
		||||
		dictToRegister[@"Path"] = path;
 | 
			
		||||
        // Add container information if available
 | 
			
		||||
        if (containerPath) {
 | 
			
		||||
            dictToRegister[@"Container"] = containerPath;
 | 
			
		||||
            dictToRegister[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(containerPath, appContainerized);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		dictToRegister[@"SignerOrganization"] = @"Apple Inc.";
 | 
			
		||||
		dictToRegister[@"SignatureVersion"] = @132352;
 | 
			
		||||
		dictToRegister[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
 | 
			
		||||
		dictToRegister[@"IsAdHocSigned"] = @YES;
 | 
			
		||||
		dictToRegister[@"LSInstallType"] = @1;
 | 
			
		||||
		dictToRegister[@"HasMIDBasedSINF"] = @0;
 | 
			
		||||
		dictToRegister[@"MissingSINF"] = @0;
 | 
			
		||||
		dictToRegister[@"FamilyID"] = @0;
 | 
			
		||||
		dictToRegister[@"IsOnDemandInstallCapable"] = @0;
 | 
			
		||||
        // Additional registration details
 | 
			
		||||
        dictToRegister[@"IsDeletable"] = @(![appBundleID isEqualToString:@"com.opa334.TrollStore"] && kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_15_0);
 | 
			
		||||
        dictToRegister[@"Path"] = path;
 | 
			
		||||
        dictToRegister[@"SignerOrganization"] = @"Apple Inc.";
 | 
			
		||||
        dictToRegister[@"SignatureVersion"] = @132352;
 | 
			
		||||
        dictToRegister[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
 | 
			
		||||
        dictToRegister[@"IsAdHocSigned"] = @YES;
 | 
			
		||||
        dictToRegister[@"LSInstallType"] = @1;
 | 
			
		||||
        dictToRegister[@"HasMIDBasedSINF"] = @0;
 | 
			
		||||
        dictToRegister[@"MissingSINF"] = @0;
 | 
			
		||||
        dictToRegister[@"FamilyID"] = @0;
 | 
			
		||||
        dictToRegister[@"IsOnDemandInstallCapable"] = @0;
 | 
			
		||||
 | 
			
		||||
		NSString *teamIdentifier = constructTeamIdentifierForEntitlements(entitlements);
 | 
			
		||||
		if (teamIdentifier) dictToRegister[@"TeamIdentifier"] = teamIdentifier;
 | 
			
		||||
        // Add team identifier if available
 | 
			
		||||
        NSString *teamIdentifier = constructTeamIdentifierForEntitlements(entitlements);
 | 
			
		||||
        if (teamIdentifier) {
 | 
			
		||||
            dictToRegister[@"TeamIdentifier"] = teamIdentifier;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		// Add group containers
 | 
			
		||||
        // Add group containers
 | 
			
		||||
        NSDictionary *appGroupContainers = constructGroupsContainersForEntitlements(entitlements, NO);
 | 
			
		||||
        NSDictionary *systemGroupContainers = constructGroupsContainersForEntitlements(entitlements, YES);
 | 
			
		||||
        NSMutableDictionary *groupContainers = [NSMutableDictionary new];
 | 
			
		||||
        [groupContainers addEntriesFromDictionary:appGroupContainers];
 | 
			
		||||
        [groupContainers addEntriesFromDictionary:systemGroupContainers];
 | 
			
		||||
 | 
			
		||||
		NSDictionary *appGroupContainers = constructGroupsContainersForEntitlements(entitlements, NO);
 | 
			
		||||
		NSDictionary *systemGroupContainers = constructGroupsContainersForEntitlements(entitlements, YES);
 | 
			
		||||
		NSMutableDictionary *groupContainers = [NSMutableDictionary new];
 | 
			
		||||
		[groupContainers addEntriesFromDictionary:appGroupContainers];
 | 
			
		||||
		[groupContainers addEntriesFromDictionary:systemGroupContainers];
 | 
			
		||||
		if (groupContainers.count) {
 | 
			
		||||
			if (appGroupContainers.count) {
 | 
			
		||||
				dictToRegister[@"HasAppGroupContainers"] = @YES;
 | 
			
		||||
			}
 | 
			
		||||
			if (systemGroupContainers.count) {
 | 
			
		||||
				dictToRegister[@"HasSystemGroupContainers"] = @YES;
 | 
			
		||||
			}
 | 
			
		||||
			dictToRegister[@"GroupContainers"] = groupContainers.copy;
 | 
			
		||||
		}
 | 
			
		||||
        if (groupContainers.count) {
 | 
			
		||||
            if (appGroupContainers.count) {
 | 
			
		||||
                dictToRegister[@"HasAppGroupContainers"] = @YES;
 | 
			
		||||
            }
 | 
			
		||||
            if (systemGroupContainers.count) {
 | 
			
		||||
                dictToRegister[@"HasSystemGroupContainers"] = @YES;
 | 
			
		||||
            }
 | 
			
		||||
            dictToRegister[@"GroupContainers"] = groupContainers.copy;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		// Add plugins
 | 
			
		||||
        // Add plugins
 | 
			
		||||
        NSString *pluginsPath = [path stringByAppendingPathComponent:@"PlugIns"];
 | 
			
		||||
        NSArray *plugins = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:nil];
 | 
			
		||||
 | 
			
		||||
		NSString *pluginsPath = [path stringByAppendingPathComponent:@"PlugIns"];
 | 
			
		||||
		NSArray *plugins = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:nil];
 | 
			
		||||
        NSMutableDictionary *bundlePlugins = [NSMutableDictionary dictionary];
 | 
			
		||||
 | 
			
		||||
		NSMutableDictionary *bundlePlugins = [NSMutableDictionary dictionary];
 | 
			
		||||
		for (NSString *pluginName in plugins) {
 | 
			
		||||
			NSString *pluginPath = [pluginsPath stringByAppendingPathComponent:pluginName];
 | 
			
		||||
        for (NSString *pluginName in plugins) {
 | 
			
		||||
            NSString *pluginPath = [pluginsPath stringByAppendingPathComponent:pluginName];
 | 
			
		||||
 | 
			
		||||
			NSDictionary *pluginInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[pluginPath stringByAppendingPathComponent:@"Info.plist"]];
 | 
			
		||||
			NSString *pluginBundleID = [pluginInfoPlist objectForKey:@"CFBundleIdentifier"];
 | 
			
		||||
            NSDictionary *pluginInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[pluginPath stringByAppendingPathComponent:@"Info.plist"]];
 | 
			
		||||
            NSString *pluginBundleID = [pluginInfoPlist objectForKey:@"CFBundleIdentifier"];
 | 
			
		||||
 | 
			
		||||
			if (!pluginBundleID) continue;
 | 
			
		||||
			NSString *pluginExecutablePath = [pluginPath stringByAppendingPathComponent:pluginInfoPlist[@"CFBundleExecutable"]];
 | 
			
		||||
			NSDictionary *pluginEntitlements = dumpEntitlementsFromBinaryAtPath(pluginExecutablePath);
 | 
			
		||||
			NSString *pluginDataContainerID = pluginBundleID;
 | 
			
		||||
			BOOL pluginContainerized = constructContainerizationForEntitlements(pluginEntitlements, &pluginDataContainerID);
 | 
			
		||||
            if (!pluginBundleID) continue;
 | 
			
		||||
 | 
			
		||||
			MCMContainer *pluginContainer = [NSClassFromString(@"MCMPluginKitPluginDataContainer") containerWithIdentifier:pluginDataContainerID createIfNecessary:YES existed:nil error:nil];
 | 
			
		||||
			NSString *pluginContainerPath = [pluginContainer url].path;
 | 
			
		||||
            NSString *pluginExecutablePath = [pluginPath stringByAppendingPathComponent:pluginInfoPlist[@"CFBundleExecutable"]];
 | 
			
		||||
            NSDictionary *pluginEntitlements = dumpEntitlementsFromBinaryAtPath(pluginExecutablePath);
 | 
			
		||||
            NSString *pluginDataContainerID = pluginBundleID;
 | 
			
		||||
            BOOL pluginContainerized = constructContainerizationForEntitlements(pluginEntitlements, &pluginDataContainerID);
 | 
			
		||||
 | 
			
		||||
			NSMutableDictionary *pluginDict = [NSMutableDictionary dictionary];
 | 
			
		||||
            MCMContainer *pluginContainer = [NSClassFromString(@"MCMPluginKitPluginDataContainer") containerWithIdentifier:pluginDataContainerID createIfNecessary:YES existed:nil error:nil];
 | 
			
		||||
            NSString *pluginContainerPath = [pluginContainer url].path;
 | 
			
		||||
 | 
			
		||||
			// Add entitlements
 | 
			
		||||
			if (pluginEntitlements) {
 | 
			
		||||
				pluginDict[@"Entitlements"] = pluginEntitlements;
 | 
			
		||||
			}
 | 
			
		||||
            NSMutableDictionary *pluginDict = [NSMutableDictionary dictionary];
 | 
			
		||||
 | 
			
		||||
			// Misc
 | 
			
		||||
            // Add entitlements to the plugin dictionary
 | 
			
		||||
            if (pluginEntitlements) {
 | 
			
		||||
                pluginDict[@"Entitlements"] = pluginEntitlements;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			pluginDict[@"ApplicationType"] = @"PluginKitPlugin";
 | 
			
		||||
			pluginDict[@"CFBundleIdentifier"] = pluginBundleID;
 | 
			
		||||
			pluginDict[@"CodeInfoIdentifier"] = pluginBundleID;
 | 
			
		||||
			pluginDict[@"CompatibilityState"] = @0;
 | 
			
		||||
            // Miscellaneous plugin information
 | 
			
		||||
            pluginDict[@"ApplicationType"] = @"PluginKitPlugin";
 | 
			
		||||
            pluginDict[@"CFBundleIdentifier"] = pluginBundleID;
 | 
			
		||||
            pluginDict[@"CodeInfoIdentifier"] = pluginBundleID;
 | 
			
		||||
            pluginDict[@"CompatibilityState"] = @0;
 | 
			
		||||
 | 
			
		||||
			pluginDict[@"IsContainerized"] = @(pluginContainerized);
 | 
			
		||||
			if (pluginContainerPath) {
 | 
			
		||||
				pluginDict[@"Container"] = pluginContainerPath;
 | 
			
		||||
				pluginDict[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(pluginContainerPath, pluginContainerized);
 | 
			
		||||
			}
 | 
			
		||||
			pluginDict[@"Path"] = pluginPath;
 | 
			
		||||
			pluginDict[@"PluginOwnerBundleID"] = appBundleID;
 | 
			
		||||
			pluginDict[@"SignerOrganization"] = @"Apple Inc.";
 | 
			
		||||
			pluginDict[@"SignatureVersion"] = @132352;
 | 
			
		||||
			pluginDict[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
 | 
			
		||||
            pluginDict[@"IsContainerized"] = @(pluginContainerized);
 | 
			
		||||
            if (pluginContainerPath) {
 | 
			
		||||
                pluginDict[@"Container"] = pluginContainerPath;
 | 
			
		||||
                pluginDict[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(pluginContainerPath, pluginContainerized);
 | 
			
		||||
            }
 | 
			
		||||
            pluginDict[@"Path"] = pluginPath;
 | 
			
		||||
            pluginDict[@"PluginOwnerBundleID"] = appBundleID;
 | 
			
		||||
            pluginDict[@"SignerOrganization"] = @"Apple Inc.";
 | 
			
		||||
            pluginDict[@"SignatureVersion"] = @132352;
 | 
			
		||||
            pluginDict[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
 | 
			
		||||
 | 
			
		||||
			NSString *pluginTeamIdentifier = constructTeamIdentifierForEntitlements(pluginEntitlements);
 | 
			
		||||
			if (pluginTeamIdentifier) pluginDict[@"TeamIdentifier"] = pluginTeamIdentifier;
 | 
			
		||||
            // Add team identifier if available for the plugin
 | 
			
		||||
            NSString *pluginTeamIdentifier = constructTeamIdentifierForEntitlements(pluginEntitlements);
 | 
			
		||||
            if (pluginTeamIdentifier) {
 | 
			
		||||
                pluginDict[@"TeamIdentifier"] = pluginTeamIdentifier;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			// Add plugin group containers
 | 
			
		||||
            // Add plugin group containers
 | 
			
		||||
            NSDictionary *pluginAppGroupContainers = constructGroupsContainersForEntitlements(pluginEntitlements, NO);
 | 
			
		||||
            NSDictionary *pluginSystemGroupContainers = constructGroupsContainersForEntitlements(pluginEntitlements, YES);
 | 
			
		||||
            NSMutableDictionary *pluginGroupContainers = [NSMutableDictionary new];
 | 
			
		||||
            [pluginGroupContainers addEntriesFromDictionary:pluginAppGroupContainers];
 | 
			
		||||
            [pluginGroupContainers addEntriesFromDictionary:pluginSystemGroupContainers];
 | 
			
		||||
 | 
			
		||||
			NSDictionary *pluginAppGroupContainers = constructGroupsContainersForEntitlements(pluginEntitlements, NO);
 | 
			
		||||
			NSDictionary *pluginSystemGroupContainers = constructGroupsContainersForEntitlements(pluginEntitlements, YES);
 | 
			
		||||
			NSMutableDictionary *pluginGroupContainers = [NSMutableDictionary new];
 | 
			
		||||
			[pluginGroupContainers addEntriesFromDictionary:pluginAppGroupContainers];
 | 
			
		||||
			[pluginGroupContainers addEntriesFromDictionary:pluginSystemGroupContainers];
 | 
			
		||||
			if (pluginGroupContainers.count) {
 | 
			
		||||
				if (pluginAppGroupContainers.count) {
 | 
			
		||||
					pluginDict[@"HasAppGroupContainers"] = @YES;
 | 
			
		||||
				}
 | 
			
		||||
				if (pluginSystemGroupContainers.count) {
 | 
			
		||||
					pluginDict[@"HasSystemGroupContainers"] = @YES;
 | 
			
		||||
				}
 | 
			
		||||
				pluginDict[@"GroupContainers"] = pluginGroupContainers.copy;
 | 
			
		||||
			}
 | 
			
		||||
            if (pluginGroupContainers.count) {
 | 
			
		||||
                if (pluginAppGroupContainers.count) {
 | 
			
		||||
                    pluginDict[@"HasAppGroupContainers"] = @YES;
 | 
			
		||||
                }
 | 
			
		||||
                if (pluginSystemGroupContainers.count) {
 | 
			
		||||
                    pluginDict[@"HasSystemGroupContainers"] = @YES;
 | 
			
		||||
                }
 | 
			
		||||
                pluginDict[@"GroupContainers"] = pluginGroupContainers.copy;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
			[bundlePlugins setObject:pluginDict forKey:pluginBundleID];
 | 
			
		||||
		}
 | 
			
		||||
		[dictToRegister setObject:bundlePlugins forKey:@"_LSBundlePlugins"];
 | 
			
		||||
            [bundlePlugins setObject:pluginDict forKey:pluginBundleID];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		if (![workspace registerApplicationDictionary:dictToRegister]) {
 | 
			
		||||
			NSLog(@"Error: Unable to register %@", path);
 | 
			
		||||
			NSLog(@"Used dictionary: {");
 | 
			
		||||
			[dictToRegister enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSObject *obj, BOOL *stop) {
 | 
			
		||||
				NSLog(@"%@ = %@", key, obj);
 | 
			
		||||
			}];
 | 
			
		||||
			NSLog(@"}");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		NSURL *url = [NSURL fileURLWithPath:path];
 | 
			
		||||
		if (![workspace unregisterApplication:url]) {
 | 
			
		||||
			NSLog(@"Error: Unable to register %@", path);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return true;
 | 
			
		||||
        // Add bundle plugins information to the main dictionary
 | 
			
		||||
        [dictToRegister setObject:bundlePlugins forKey:@"_LSBundlePlugins"];
 | 
			
		||||
 | 
			
		||||
        // Attempt to register the application using the provided dictionary
 | 
			
		||||
        if (![workspace registerApplicationDictionary:dictToRegister]) {
 | 
			
		||||
            // Registration failed, log error and return false
 | 
			
		||||
            NSLog(@"Error: Unable to register %@", path);
 | 
			
		||||
            NSLog(@"Used dictionary: {");
 | 
			
		||||
            [dictToRegister enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSObject *obj, BOOL *stop) {
 | 
			
		||||
                NSLog(@"%@ = %@", key, obj);
 | 
			
		||||
            }];
 | 
			
		||||
            NSLog(@"}");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        // Unregister application if needed
 | 
			
		||||
        NSURL *url = [NSURL fileURLWithPath:path];
 | 
			
		||||
        if (![workspace unregisterApplication:url]) {
 | 
			
		||||
            // Unregistration failed, log error and return false
 | 
			
		||||
            NSLog(@"Error: Unable to unregister %@", path);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Successful registration or unregistration
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user