Mac OS系统自身包含有转换plist的工具:plutil.其中-p是以human可读方式显示plist文件,而convert就是转换参数,其中支持的格式有:xml,二进制和json。下面拿一个实际例子测试下,该plist文件是二进制文件:
apple@kissAir: Contents$ls
Info.plist MacOS Resources
apple@kissAir: Contents$cat I*
bplist00?
!"#$%&'()*(WDTXcodeYDTSDKName_NSPrefPaneIconFile\CFBundleNameZDTSDKBuild_CFBundleDevelopmentRegion_CFBundleVersion_BuildMachineOSBuild_NSPrincipalClass]NSMainNibFile_NSPrefPaneSearchParameters_SSupportsSuddenTermination_CFBundlePackageType_CFBundleInfoDictionaryVersion_CFBundleExecutableZDTCompiler_CFBundleIdentifier_DTPlatformVersion\DTXcodeBuild_CFBundleSignature_NSPrefPaneIconLabel_DTPlatformBuildT0463Zmacosx10.6_FlashPlayerPreferences.png\Flash PlayerV10K549WEnglishZ15.0.0.239U12F45_FSPreferencesMain_FlashPlayerPreferencesTtrueTBNDLS6.0\Flash PlayerP_ com.adobe.flashplayerpreferencesRGMV4H1503T????\Flash Playe7?I^kv??????,Lal????????
'28Lejos??????+?
显示其内容:
plutil -p I*
{
"DTXcode" => "0463"
"DTSDKName" => "macosx10.6"
"NSPrefPaneIconFile" => "FlashPlayerPreferences.png"
"CFBundleName" => "Flash Player"
"DTSDKBuild" => "10K549"
"CFBundleDevelopmentRegion" => "English"
"CFBundleVersion" => "15.0.0.239"
"BuildMachineOSBuild" => "12F45"
"NSPrincipalClass" => "FSPreferencesMain"
"NSMainNibFile" => "FlashPlayerPreferences"
"NSPrefPaneSearchParameters" => "FlashPlayerPreferences"
"NSSupportsSuddenTermination" => "true"
"CFBundlePackageType" => "BNDL"
"CFBundleInfoDictionaryVersion" => "6.0"
"CFBundleExecutable" => "Flash Player"
"DTCompiler" => ""
"CFBundleIdentifier" => "com.adobe.flashplayerpreferences"
"DTPlatformVersion" => "GM"
"DTXcodeBuild" => "4H1503"
"CFBundleSignature" => "????"
"NSPrefPaneIconLabel" => "Flash Player"
"DTPlatformBuild" => "4H1503"
}
转换:
apple@kissAir: Contents$plutil -convert xml1 I* -o ~/x
这是转换后的内容:
apple@kissAir: ~$file x
x: XML document text
apple@kissAir: ~$cat x
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>12F45</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Flash Player</string>
<key>CFBundleIdentifier</key>
<string>com.adobe.flashplayerpreferences</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Flash Player</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>15.0.0.239</string>
<key>DTCompiler</key>
<string></string>
<key>DTPlatformBuild</key>
<string>4H1503</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>10K549</string>
<key>DTSDKName</key>
<string>macosx10.6</string>
<key>DTXcode</key>
<string>0463</string>
<key>DTXcodeBuild</key>
<string>4H1503</string>
<key>NSMainNibFile</key>
<string>FlashPlayerPreferences</string>
<key>NSPrefPaneIconFile</key>
<string>FlashPlayerPreferences.png</string>
<key>NSPrefPaneIconLabel</key>
<string>Flash Player</string>
<key>NSPrefPaneSearchParameters</key>
<string>FlashPlayerPreferences</string>
<key>NSPrincipalClass</key>
<string>FSPreferencesMain</string>
<key>NSSupportsSuddenTermination</key>
<string>true</string>
</dict>
</plist>