Search code examples
swiftxcodeplist

Remove keys without data from Info.plist


I have an iOS app that has the following key in Info.plist

<key>UISupportedExternalAccessoryProtocols</key>
    <array>
        <string>$(MYAPP_EXTERNAL_ACCESSORIES)</string>
    </array>

We have a client and merchant version of the app, only the latter gets a value assigned here (a bluetooth printer). When archiving for the client, we get the following error during the process of uploading to iTunes Connect:

ERROR ITMS-90110: "This bundle is invalid. The key UISupportedExternalAccessoryProtocols in the Info.plist file must be an array of non-empty strings."

I found ways to change Info.plist using a script (adding/removing something from an existing key) but not how to remove a key completely for some build configurations, or if it is empty.

What would be the best solution for this?

Thanks.


Solution

  • You indicate you already know how to work with a build script. The tool you want to use in your script is plutil:

    plutil -insert <keypath> -<type> <value> <path_to_file>
    

    or

    plutil -remove <keypath> <path_to_file>