-2

I have a commandline tool written in swift that edits xcode project settings.

I need to be able to delete a 'key' from the .entitlements file.

The specific situation is that I have some projects that do not support associated domains but I need to remove the whole

    <key>com.apple.developer.associated-domains</key>
<array>
    <string>applinks:xxx.page.link</string>
</array>

from the file in a gracefull way because leaving just the array empty means the project indicates using associated domains and it does not.

so in short using swift remove a key from a plist.

Ágúst Rafnsson
  • 601
  • 1
  • 5
  • 9
  • 1
    The best way must be to load the whole list into memory, delete the key/data and write it back to file. See for instance https://stackoverflow.com/questions/40436895/how-to-read-plist-without-using-nsdictionary-in-swift – Joakim Danielson Oct 07 '19 at 09:27

1 Answers1

4

The simplest solution would be using PlistBuddy.

You'll have to launch a shell command with something like this: https://stackoverflow.com/a/26973384/3393964

The command would be something like:

/usr/libexec/PlistBuddy -c 'Delete :com.apple.developer.associated-domains' Info.plist
Casper Zandbergen
  • 3,419
  • 2
  • 25
  • 49