日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

PlistBuddy简单使用

發布時間:2024/6/30 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PlistBuddy简单使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

PlistBuddy簡單使用

由于PlistBuddy并不在Mac默認的Path里,所以我們得通過絕對路徑來引用這個工具:

  • 查看幫助
/usr/libexec/PlistBuddy --help

下面我們來看看PlistBuddy的簡單使用

打印:
  • 初始化一個 info.plist 文件

初始化info.plist
  • 打印info.plist文件
/usr/libexec/PlistBuddy -c "print" info.plist
  • 在終端輸入上述命令后如下所示:
添加

  • 添加普通字段:
/usr/libexec/PlistBuddy -c 'Add :Version string 1.0' info.plist
  • 添加數組字段,分兩步走,注意:key之間用 : 隔開,且不能有空格:
# 先添加key值 /usr/libexec/PlistBuddy -c 'Add :Application array' info.plist # 添加value值 yans67deMacBook-Pro:needfiles huangyg$ /usr/libexec/PlistBuddy -c 'Add :Application: string app1' info.plist yans67deMacBook-Pro:needfiles huangyg$ /usr/libexec/PlistBuddy -c 'Add :Application: string app2' info.plist yans67deMacBook-Pro:needfiles huangyg$ /usr/libexec/PlistBuddy -c 'Add :Application: string app3' info.plist
  • 添加字典字段,分兩步走:
# 先添加key值 /usr/libexec/PlistBuddy -c 'Add :Person dict' info.plist # 添加value值, /usr/libexec/PlistBuddy -c 'Add :Age string secret' info.plist /usr/libexec/PlistBuddy -c 'Add :Person:Name string yans67' info.plist /usr/libexec/PlistBuddy -c 'Add :Person:sex string boy' info.plist /usr/libexec/PlistBuddy -c 'Add :Person:weight string 65' info.plist
輸出

  • 打印字段相應的值:
/usr/libexec/PlistBuddy -c 'Print :Person' info.plist
  • 在array中我們還可以根據下標打印某個特定的值
/usr/libexec/PlistBuddy -c 'Print :Application:2' info.plist
刪除

  • 刪除字段相應的值:
/usr/libexec/PlistBuddy -c 'Delete :Version' info.plist
修改

  • 修改某個字段相應的值:
/usr/libexec/PlistBuddy -c 'Set :Application:1 string "thi is app1"' info.plist
合并

  • 當有兩個plist文件的時候,我們可以對其進行合并操作
# 將A.plist 合并到 B.plist中 /usr/libexec/PlistBuddy -c 'Merge A.plist' B.plist
終端中會提示B.plist中有重復的鍵值,所以默認跳過該鍵值的合并
合并前

原文鏈接:?http://www.jianshu.com/p/2167f755c47e

參考鏈接:?http://shaojunxiao.com/2017/03/23/使用PlistBuddy修改info-plist文件/?utm_source=tuicool&utm_medium=referral

     ?https://segmentfault.com/a/1190000002423661

?

轉載于:https://www.cnblogs.com/xieyulin/p/7060524.html

總結

以上是生活随笔為你收集整理的PlistBuddy简单使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。