如何从 shell 脚本读取 plist 信息(bundle id) [英] How to read plist information (bundle id) from a shell script

查看:36
本文介绍了如何从 shell 脚本读取 plist 信息(bundle id)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个脚本,该脚本可以从应用程序的 Info.plist 中读取 Bundle Identifier 或版本号等信息.Xcode 似乎没有在它的环境变量中提供该信息.有没有其他方法可以让它们进入 sh/bash?

I'd like to write a script that can read info like Bundle Identifier or maybe version number from the Info.plist of the app. Xcode doesn't seem to give that information in it's environment variables. Is there any other way to get them in sh/bash?

推荐答案

defaults 命令可以读/写任何 plist 文件,只需给它一个减去 .plist 的路径代码>扩展名:

The defaults command can read/write to any plist file, just give it a path minus the .plist extension:

$ defaults read /Applications/Preview.app/Contents/Info CFBundleIdentifier

com.apple.Preview

这会直接从应用程序包的 Info.plist 文件中提取 CFBundleIdentifier 值.

This pulls the CFBundleIdentifier value directly from the application bundle's Info.plist file.

默认值也适用于二进制 plist,无需任何额外步骤.

Defaults also works with binary plists without any extra steps.

这篇关于如何从 shell 脚本读取 plist 信息(bundle id)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆