根据名称或包标识符获取iOS应用程序的路径 [英] Get path to iOS application based on name or bundle identifier

查看:189
本文介绍了根据名称或包标识符获取iOS应用程序的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有更简单的方法来获取iOS应用程序的路径,而不是搜索 / var / mobile / Applications

Is there an easier way to get the path to an iOS application, than searching /var/mobile/Applications?

我知道名称和包标识符,但路径在不同的iOS设备上不一致。

I know both the name and the bundle identifier, however the path is not consistent on different iOS devices.

这是用于越狱调整,所以我可以使用PrivateFrameworks和Apple不允许的其他代码。

This is for use in a jailbreak tweak, so I can use PrivateFrameworks and other code not allowed by Apple.

推荐答案

如果你正在运行在Springboard中执行的代码,这应该是相当简单。获取 SBApplicationController sharedInstance ,然后获取 SBApplication 你正在寻找 applicationWithDisplayIdentifier:方法(或使用您选择的任何方法)。 SBApplication 类包含路径 containerPath 的属性,以及捆绑(以及其他许多),其中一个应该是您正在寻找的。我自己没试过,所以我不能保证它会工作,但基于快速浏览一下Springboard头文件(你可以看看这里,或自己转储头文件),它应该可以工作。

If you're running code that executes in Springboard, this should be fairly simple. Get SBApplicationController's sharedInstance, then get the SBApplication you're looking for with the applicationWithDisplayIdentifier: method (or using whatever method you choose). The SBApplication class contains properties for path, containerPath, and bundle (among many others), one of which should be what you're looking for. I haven't tried this myself, so I can't guarantee it'll work, but based on a quick glance at the Springboard header files (you can take a look here, or dump the header files yourself), it should work.

另一方面,如果你没有从Springboard运行(即,如果你正在制作一个真正的App Store风格的应用程序),那么你可能会运气不好。您可以查看与Springboard的进程间通信,看看是否可以在那里完成某些事情,但它可能比它的价值更麻烦。

On the other hand, if you're not running from Springboard (ie. if you're making an actual App Store-style application), then you may be out of luck. You could look into inter-process communication with Springboard and see if something can be done there, but it'd probably be more trouble than it's worth.

这篇关于根据名称或包标识符获取iOS应用程序的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆