2

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

4

5 回答 5

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 上运行良好。

于 2016-07-13T07:22:45.787 回答
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。

于 2013-03-11T15:14:56.630 回答
2

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

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

于 2013-03-11T16:27:44.087 回答
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;

}
于 2018-02-27T11:23:08.930 回答
0

尝试这个。

NSArray *appList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/Applications" error:nil];
NSLog(@"%@",appList);
于 2014-06-16T08:38:43.840 回答