iOS更改捆绑标识符使用PlistBuddy无法正常工作

我正在尝试以编程方式更改我的XCode项目的包标识符.

$/usr/libexec/PlistBuddy -c “Set :CFBundleIndentifier
com.myIdentifier.appName” MyApp-Info.plist

但我一直得到错误

Set: Entry,“:CFBundleIndentifier”,Does Not Exist

这就是我的Info-Plist的样子,它有CFBundleIndentifier的条目.

<?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>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundledisplayName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>Icon-120</string>
                <string>Icon.png</string>
                <string>Icon@2x.png</string>
                <string>Icon-iPad.png</string>
                <string>Icon-iPad@2x.png</string>
            </array>
        </dict>
    </dict>
    <key>CFBundleIcons~ipad</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>Icon-152</string>
                <string>Icon-76</string>
                <string>Icon-120</string>
                <string>Icon.png</string>
                <string>Icon@2x.png</string>
                <string>Icon-iPad.png</string>
                <string>Icon-iPad@2x.png</string>
            </array>
        </dict>
    </dict>
    <key>CFBundleIdentifier</key>
    <string>com.myOldIdentifier.app</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>3.0.12</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundLeversion</key>
    <string>1.0</string>
    <key>LSApplicationCategoryType</key>
    <string></string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIAppFonts</key>
    <array>
        <string>Gotham-Bold.otf</string>
        <string>Gotham-BoldItalic.otf</string>
        <string>Gotham-Book.otf</string>
        <string>Gotham-BookItalic.otf</string>
        <string>Gotham-Light.otf</string>
        <string>Gotham-LightItalic.otf</string>
        <string>Gotham-Medium.otf</string>
        <string>Gotham-MediumItalic.otf</string>
    </array>
    <key>UIApplicationExitsOnSuspend</key>
    <false/>
    <key>UIStatusBarHidden</key>
    <true/>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleBlackOpaque</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarappearance</key>
    <true/>
</dict>
</plist>

也许我正在使用PlistBuddy错误.如何使用命令行更改XCode项目的Bundle标识符.我需要在脚本中添加它.

解决方法

你拼错了钥匙的名字.它应该是CFBundleIdentifier而不是CFBundleIndentifier

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...