以编程方式在iPhone上列出所有已安装的应用

时间:2013-03-11 06:21:56

标签: iphone ios jailbreak

我需要在编码的帮助下列出iPhone上所有已安装的应用程序。我正在使用越狱的iPhone。我使用过ihasapp API,但它没有显示所有已安装应用的完整列表。请帮我解释一下代码。

5 个答案:

答案 0 :(得分:8)

我的iPhone中列出了所有已安装的应用程序。它使用私有框架,但它不是监狱设备。了解下面的一段代码。

#include <objc/runtime.h>

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

    SEL selectorALL = NSSelectorFromString(@"allApplications");
    NSLog(@"apps: %@", [workspace performSelector:selectorALL]);

我已经尝试过这段代码,它在iOS9上运行良好。

答案 1 :(得分:4)

有一个私有API SBSCopyApplicationDisplayIdentifiers

它的签名是

CFArrayRef SBSCopyApplicationDisplayIdentifiers(bool onlyActive,bool debuggable);

如果链接到SpringboardServices框架并使用它,它将返回已安装应用程序的列表。

更新1

以下是从here

复制的使用示例
CFArrayRef SBSCopyApplicationDisplayIdentifiers(bool onlyActive, bool debuggable);

int main() {
    char buf[1024];
    CFArrayRef ary = SBSCopyApplicationDisplayIdentifiers(false, false);
    for(CFIndex i = 0; i < CFArrayGetCount(ary); i++) {
        CFStringGetCString(CFArrayGetValueAtIndex(ary, i),buf, sizeof(buf), kCFStringEncodingUTF8);
        printf("%s\n", buf);
    }
    return 0;
}

不要忘记链接到pravite框架SpringboardServices。

答案 2 :(得分:2)

我自己使用AppList库来获取所有已安装应用的列表。它使用私有框架,因此它也只是越狱。请查看https://github.com/rpetrich/AppList

更新:@Nate对此已经被问及回答是正确的。查看:Get list of all installed apps

答案 3 :(得分:1)

我搜索了很多以获得iOS 11上安装的应用列表。但是有代码可以检查当前安装在此设备上的应用程序。

//If the device is iOS11
if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {
    NSBundle *container = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/MobileContainerManager.framework"];
    if ([container load]) {
        Class appContainer = NSClassFromString(@"MCMAppContainer");

        id test = [appContainer performSelector:@selector(containerWithIdentifier:error:) withObject:bundleId withObject:nil];
        NSLog(@"%@",test);
        if (test) {
            return YES;
        } else {
            return NO;
        }
    }
    return NO;

}

答案 4 :(得分:0)

试试这个。

NSArray *appList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/Applications" error:nil];
NSLog(@"%@",appList);