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

问题描述 投票:0回答:6

我需要借助编码列出 iPhone 上所有已安装的应用程序。我使用的是越狱的 iPhone。我已经使用了 ihasapp API,但它没有向我显示所有已安装应用程序的完整列表。请帮我写一下代码。

iphone ios jailbreak
6个回答
9
投票

我获得了 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 上运行良好。


4
投票

有一个私有API SBSCopyApplicationDisplayIdentifiers

签名如下

CFArrayRef SBSCopyApplicationDisplayIdentifiers(bool onlyActive, bool debuggable);

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

更新1

这里是从这里

复制的用法示例
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
投票

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

更新:@Nate 对于已经被询问和回答的问题是正确的。查看:获取所有已安装应用程序的列表


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;

}

0
投票

试试这个。

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

0
投票

我放弃了。我已经尝试这样做很长时间了。 为什么苹果就没有办法???? 我有 1127 个应用程序。 我将浏览配置器中的详细列表,记录每一页。 然后我可以去 SnapMotion 分别提取每个页面。 然后我使用 PDFExpert 将它们合并为一个文件。 最后,我使用 PDFExpert 对文件进行 OCR。

© www.soinside.com 2019 - 2024. All rights reserved.