iOS7中缺少safari history.list文件



我想以编程方式访问safari历史文件,在回答了这里的几个问题后,我发现safari历史存储在以下路径:/var/mobile/Library/Safari/History.plist,但我看不到history.plist文件,safari目录中只有与safari书签相关的文件。

History.plist文件是否已移动到iOS7中的其他路径
我使用iFile在越狱的iPhone 5S(iOS 7.1.1)和iPhone 5C(iOS 7.1.2)上检查过它。

您可以转到:

/var/mobile/Applications/-safari app identifier-/Library/Safari/History.plist

要查找safari(或任何其他系统/用户应用程序)的完整路径,可以检查名为com.apple.mobile.installation.plist的plist。此文件位于/var/mobile/Library/Caches/com.apple.mobile.installation.plist。这个plist文件包含我们想要的内容。plist如下所示:

-Root
    ...
    +System (Dictionary)
    +User (Dictionary)
    ...

Safari是一个系统应用程序,因此在系统字典中,我们可以看到一个名为com.apple.mobilesafari的密钥,它也是字典的密钥。这本字典包含一个字符串键控的Path,这正是您想要的。正如您所看到的,通过了解应用程序类型和捆绑包标识符,可以知道任何其他应用程序的路径。所以你的代码应该是这样的:

- (NSString*) safariPath {
    return [self applicaitonFullPath:@"com.apple.mobilesafari" appType:@"System"];
}
- (NSString*) applicaitonFullPath:(NSString*)bundleIdentifier appType:(NSString*)appType {
    //appType shoud be `System` or `User` case sensitive!!
    NSDictionary *mobileInstallationDict = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Caches/com.apple.mobile.installation.plist"];
    return mobileInstallationDict[appType][bundleIdentifier][@"Path"];
}

检查此路径:

/private/var/mobile/Applications/Library/Safari/History.plist

最新更新