I am trying to set the description of an image. The metadata tag necessary to add the description is of type alternateText
.
I create the child tag with the new description value:
let childTag = CGImageMetadataTagCreate(identifier.section.namespace, identifier.section.prefix, "[x-default]" as CFString, .string, value as CFTypeRef)
I then set the description tag like this:
let parentTag = CGImageMetadataTagCreate(identifier.section.namespace, identifier.section.prefix, identifier.tagKey, .alternateText, [childTag] as CFTypeRef)
let result = CGImageMetadataSetTagWithPath(metadata, nil, identifier.tagKey, parentTag)
However, when I write the image file, I get a runtime error message and the operation fails:
XMP Error: AltText array items must have an xml:lang qualifier
So, I create the qualifier tag like this:
let qualifierTag = CGImageMetadataTagCreate("http://www.w3.org/XML/1998/namespace" as CFString, "xml" as CFString, "lang" as CFString, .string, "x-default" as CFTypeRef)
But I have not found a way to associate this qualifier tag to the child tag with the description value.
What is the way to do it?