如何从 shell 脚本读取 plist 信息(bundle id)

编程入门 行业动态 更新时间:2024-10-28 12:25:52
本文介绍了如何从 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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-27 02:39:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/674181.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   信息   shell   plist   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!