问题
In iOS devices, all user applications are located in /var/mobile/Applications
directory, and each app has a unique random uuid as its directory name, for instance:
/var/mobile/Applications/15FD62FD-2BEB-4C1E-A9B8-BC93E5C721CC
the uuid is 15FD62FD-2BEB-4C1E-A9B8-BC93E5C721CC
.
Now I want to get the directory by application's bundle identifier, my solution is enumerate the /var/mobile/Applications
directory, get the bundle identifier from Info.plist
and check.
This solution is rather slow, is there any quicker way to do this?
e.g. if there is a plist that records the bundle id to uuid mapping, then I can read that file to avoid directory enumeration.
回答1:
I think the file you are looking for is
/var/mobile/Library/Caches/com.apple.mobile.installation.plist
For example, it contains information like this for each app:
"com.zillow.ZillowMap" = {
ApplicationDSID = 216284405;
ApplicationType = User;
CFBundleDisplayName = Zillow;
CFBundleExecutable = ZillowMap;
CFBundleIconFiles = (
"app-icon",
"app-icon-iPad.png",
"app-icon-iPad@2x.png"
);
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
"app-icon",
"app-icon-iPad.png",
"app-icon-iPad@2x.png"
);
UIPrerenderedIcon = 1;
};
};
CFBundleIdentifier = "com.zillow.ZillowMap";
CFBundleName = ZillowMap;
CFBundleShortVersionString = "6.1.0112";
CFBundleVersion = "6.1.0112";
CodeInfoIdentifier = "com.zillow.ZillowMap";
Container = "/private/var/mobile/Applications/B9284FBE-E558-4A65-A7E4-AE20CDAD9A1D";
Entitlements = {
"application-identifier" = "JEWMY3RZ4A.com.zillow.ZillowMap";
"aps-environment" = production;
};
EnvironmentVariables = {
"CFFIXED_USER_HOME" = "/private/var/mobile/Applications/B9284FBE-E558-4A65-A7E4-AE20CDAD9A1D";
HOME = "/private/var/mobile/Applications/B9284FBE-E558-4A65-A7E4-AE20CDAD9A1D";
TMPDIR = "/private/var/mobile/Applications/B9284FBE-E558-4A65-A7E4-AE20CDAD9A1D/tmp";
};
IsUpgradeable = 1;
LSRequiresIPhoneOS = 1;
MinimumOSVersion = "5.0";
Path = "/private/var/mobile/Applications/B9284FBE-E558-4A65-A7E4-AE20CDAD9A1D/ZillowMap.app";
SequenceNumber = 2618;
SignerIdentity = "Apple iPhone OS Application Signing";
UIDeviceFamily = (
1,
2
);
UIPrerenderedIcon = 1;
};
Update
This file was removed in iOS 8: (https://www.theiphonewiki.com/wiki/Com.apple.mobile.installation.plist)
There exists a similar file for iOS 8 at /var/mobile/Library/MobileInstallation/LastLaunchServicesMap.plist
, but it might only be updated at launch (reboot).
回答2:
And here this is another solution, if your code runs in SpringBoard:
NSString *applicationBundleIdentifier = @"...";
SBApplication *application = [[SBApplicationController sharedInstance]applicationWithDisplayIdentifier:applicationBundleIdentifier];
NSString *path = application.containerPath;
来源:https://stackoverflow.com/questions/17481667/how-to-quickly-get-apps-directory-from-its-bundle-id-on-jailbroken-ios-device