Attach them after the CVPixelBufferCreate call. The attributes dictionary that can be passed to CVPixelBufferCreate is just to setup the pixel format, not to attach other attributes.
So call CVBufferSetAttachments after the CVPixelBuffer is created and set them.
P.S.: modifying CVPixelBuffer attributes is quite expensive, do it only as needed.
Topic:
Media Technologies
SubTopic:
Video