Warm tip: This article is reproduced from serverfault.com, please click

Remove a dict entry from Info.plist with plutil/PlistBuddy

发布于 2020-11-27 16:07:57

I have the following Info.plist (UTF8) file:

<?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>CFBundleDisplayName</key>
    <string>yaka</string>
    <key>CFBundleIdentifier</key>
    <string>com.whetever.youwant</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.5</string>
    <key>CFBundleVersion</key>
    <string>1.0.5</string>
    <key>CFBundleLocalizations</key>
    <array>
        <string>en</string>
        <string>fr</string>
    </array>
    <key>CFBundleDevelopmentRegion</key>
    <string>fr</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <true/>
        <key>UISceneConfigurations</key>
        <dict>
            <key>UIWindowSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>UISceneConfigurationName</key>
                    <string>Default Configuration</string>
                    <key>UISceneDelegateClassName</key>
                    <string>SceneDelegate</string>
                </dict>
            </array>
        </dict>
    </dict>
    <key>MinimumOSVersion</key>
    <string>9.3</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>CFBundleName</key>
    <string>yaka</string>
    <key>UIAppFonts</key>
    <array>
        <string>Fonts/Ubuntu-Regular.ttf</string>
        <string>Fonts/Ubuntu-Medium.ttf</string>
        <string>Fonts/Ubuntu-Light.ttf</string>
    </array>
    <key>XSAppIconAssets</key>
    <string>Assets.xcassets/AppIcon.appiconset</string>
    <key>UIFileSharingEnabled</key>
    <true/>
    <key>NSCameraUsageDescription</key>
    <string>Nous utilisons la caméra pour les videoconférences</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Nous utilisons le micro pour les videoconférences</string>
    <key>NSBonjourServices</key>
    <array>
        <string>_reveal._tcp</string>
    </array>
</dict>
</plist>

I'm trying to Remove the NSBonjourServices entry located at the end of the file using plutil or PlistBuddy but it fails miserably:

/usr/libexec/PlistBuddy -c 'Delete :NSBonjourServices' Info.plist

Encountered unexpected character \u00c2 on line 80 while looking for open tag Error Reading File: Info.plist

plutil -remove NSBonjourServices Info.plist

Info.plist: Property List error: Encountered unexpected character  on line 80 while looking for open tag / JSON error: JSON text did not start with array or object and option to allow fragments not set.

Line 80 is this one:

    <string>_reveal._tcp</string>

Questioner
Olivier MATROT
Viewed
0
mr. fixit 2020-11-28 09:27:14

Your Info.plist has an illegal character in it. You might be able to fix by deleting and retyping that one line, or the whole NSBonjourServices array.