bash 在命令行中编辑 ipa plist 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7044767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 00:34:48  来源:igfitidea点击:

Edit ipa plist file in command line

macosbashplistipa

提问by kevmalek

I'd like to change the 'bundle-identifier' string value in a plist file using the command line. Using 'defaults', how would I do this?

我想使用命令行更改 plist 文件中的“bundle-identifier”字符串值。使用“默认值”,我该怎么做?

FYI here is the plist in its entirety:

仅供参考,这里是完整的 plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>items</key>
   <array>
   <dict>
       <key>assets</key>
       <array>
           <dict>
               <key>kind</key>
               <string>software-package</string>
               <key>url</key>
               <string>http://eventpilotadmin.com/doc/clients/ISES/Eventworld2011/proofs/iphone_Eventworld2011_proof.ipa</string>
           </dict>
       </array>
       <key>metadata</key>
       <dict>
           <key>bundle-identifier</key>
           <string>com.ativsoftware.Eventworld2011</string>
           <key>bundle-version</key>
           <string>1.0</string>
           <key>kind</key>
           <string>software</string>
           <key>title</key>
           <string>Eventworld2011</string>
       </dict>
      </dict>
   </array>
</dict>
</plist>

回答by user478681

Try this:

尝试这个:

/usr/libexec/PlistBuddy -c "Set :items:0:metadata:bundle-identifier newidentifier" your.plist

回答by sorpigal

If the line format is consistent you could do it with sedlike this:

如果行格式一致,您可以这样做sed

sed -n '/bundle-identifier/{p;n;s/>.*</>new value</;};p' your.plist

In your example this would change com.ativsoftware.Eventworld2011to new value

在您的示例中,这将更com.ativsoftware.Eventworld2011改为new value

Add -ito edit in place.

添加-i到位编辑。

回答by Jon

@user478681's answer did not work for me, because of the missing step to unzip and zip the ipa file.

@ user478681 的回答对我不起作用,因为缺少解压缩和压缩 ipa 文件的步骤。

I found a sitewith those steps.

我找到了一个带有这些步骤的网站

In short:

简而言之:

unzip app.ipa
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier newidentifier" Payload/MyApp.app/Info.plist
zip -qr ResignedApp.ipa Payload

If you need to resign your app, follow the instructions on the aforementioned site.

如果您需要退出您的应用程序,请按照上述网站上的说明进行操作。

回答by user2643679

Updated version:

更新后的版本:

/usr/libexec/PlistBuddy -c "set :CFBundleIdentifier newidentifier" your.plist