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

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

问题描述

我想编写一个脚本,可以读取Bundle Identifier等信息,也可以从应用的Info.plist中读取版本号。 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?

推荐答案

默认命令可以读取/写入任何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 值/ code>文件。

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天全站免登陆