MASTG-TOOL-0135: PlistBuddy
PlistBuddy 在 macOS 上可用,允许您打印和修改 .plist
文件。它不在默认 PATH 中,但可以通过 /usr/libexec/PlistBuddy
运行。 PlistBuddy 使用自定义语法对给定的 plist 文件执行命令。
打印 Plist 文件¶
下面的示例通过指定 Print
命令来打印 iOS UnCrackable L1 的 Info.plist 文件的 ASCII 表示
/usr/libexec/PlistBuddy -c "Print" Info.plist
Dict {
DTXcode = 0821
DTSDKName = iphoneos10.2
CFBundleName = UnCrackable Level 1
UILaunchStoryboardName = LaunchScreen
CFBundleIcons~ipad = Dict {
CFBundlePrimaryIcon = Dict {
CFBundleIconFiles = Array {
AppIcon-120x20
AppIcon-129x29
AppIcon-140x40
AppIcon-157x57
AppIcon-160x60
AppIcon-150x50
AppIcon-172x72
AppIcon-176x76
AppIcon-183.5x83.5
}
}
}
DTSDKBuild = 14C89
CFBundleDevelopmentRegion = en
CFBundleVersion = 1
BuildMachineOSBuild = 15G1212
DTPlatformName = iphoneos
CFBundleShortVersionString = 1.0
UIMainStoryboardFile = Main
CFBundleSupportedPlatforms = Array {
iPhoneOS
}
CFBundlePackageType = APPL
CFBundleInfoDictionaryVersion = 6.0
UIRequiredDeviceCapabilities = Array {
armv7
}
CFBundleExecutable = UnCrackable Level 1
DTCompiler = com.apple.compilers.llvm.clang.1_0
UISupportedInterfaceOrientations~ipad = Array {
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
}
CFBundleIdentifier = sg.vp.UnCrackable1
MinimumOSVersion = 8.0
DTXcodeBuild = 8C1002
DTPlatformVersion = 10.2
LSRequiresIPhoneOS = true
UISupportedInterfaceOrientations = Array {
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
}
CFBundleDisplayName = UnCrackable1
CFBundleIcons = Dict {
CFBundlePrimaryIcon = Dict {
CFBundleIconFiles = Array {
AppIcon-120x20
AppIcon-129x29
AppIcon-140x40
AppIcon-157x57
AppIcon-160x60
}
}
}
UIDeviceFamily = Array {
1
2
}
DTPlatformBuild = 14C89
}
您还可以打印特定的条目。 字典属性通过 :
指定,数组索引从 0 开始。 下面的命令打印第三个应用程序图标格式
/usr/libexec/PlistBuddy -c "Print CFBundleIcons~ipad:CFBundlePrimaryIcon:CFBundleIconFiles:2" Info.plist
AppIcon-140x40
更改 Plist 值¶
PlistBuddy 还可以通过 Set <key> <value>
命令更改值。 以下示例更新 CFBundleDisplayName
/usr/libexec/PlistBuddy -c "Set CFBundleDisplayName 'My New App Name'" Info.plist
/usr/libexec/PlistBuddy -c "Print CFBundleDisplayName" Info.plist
My New App Name
添加和删除 Plist 值¶
可以通过指定键、值和类型来添加和删除条目
/usr/libexec/PlistBuddy -c "Add CustomDictionary dict" Info.plist
/usr/libexec/PlistBuddy -c "Add CustomDictionary:CustomProperty string 'OWASP MAS'" Info.plist
/usr/libexec/PlistBuddy -c "Print CustomDictionary" Info.plist
Dict {
CustomProperty = OWASP MAS
}