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

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

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

更新:@Nate是正确的,这已被问及回答。 检出: 获取所有安装的应用程序列表

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

有一个私人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。

尝试这个。

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