以编程方式列出iOS设备中安装的所有应用程序的版本

问题描述:

我需要以编程方式获取未越狱的iOS设备的所有已安装应用程序的版本。
是否可以实现?

I need to get the Versions of all the installed applications programmatically for non-jailbroken iOS devices. Is it Possible to achieve this?

有可能,请尝试以下代码。

That's possible, please try the below code.

Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
    NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];

    for (LSApplicationProxy *apps in [workspace performSelector:@selector(allApplications)])
    {         
        NSString *localizedName = apps.localizedName;

        if([apps.applicationType isEqualToString:@"User"])
        {
            NSLog(@"\nlocalizedName: %@",localizedName);
            NSLog(@"minimumSystemVersion: %@",apps.minimumSystemVersion);
            NSLog(@"fileSharingEnabled: %d",apps.fileSharingEnabled);
            NSLog(@"sdkVersion: %@",apps.sdkVersion);
            NSLog(@"teamID: %@",apps.teamID);
        }
    }

为此,您需要在应用程序中放置4个类:

For this you need to place 4 classes in your app:

LSApplicationWorkspace, LSResourceProxy, LSBundleProxy, LSApplicationProxy.