Get path to iOS application based on name or bundle identifier

孤人 提交于 2019-11-30 15:26:41

问题


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

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

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


回答1:


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.

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.




回答2:


If running in an app, you can define:

extern NSString* SBSCopyBundlePathForDisplayIdentifier(NSString* bundleId);

and link to the SpringboardServices framework.




回答3:


Or you can use the library AppList and then it's:

ALApplicationList *al = [ALApplicationList sharedApplicationList];
NSString *appPath = [al valueForKey:@"path" forDisplayIdentifier:bundleID];

In this case it's doing what Andrew R. mentions in his answer for you. (I assume the same requirements are necessary, i.e. must be running from Springboard.)

Update: This no longer seems to be working on iOS 11.



来源:https://stackoverflow.com/questions/9856212/get-path-to-ios-application-based-on-name-or-bundle-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!