This has nothing to do with render passes, so I don’t know why you asked this question in this thread.
That having been said, swap chain images do not belong to your program. They belong to the OS’s display engine, and you request to be able to use them. But you can only use them in accord with whatever rules the display engine allows you to.
When you called
vkGetPhysicalDeviceSurfaceCapabilitiesKHR, among the values you get is the
VkSurfaceCapabilitiesKHR::supportedUsageFlags flag field. This is a bitmask of
VkImageUsageFlagBits values that informs you of the ways you can use swap chain images.
And the only usage that Vulkan requires that all implementations provide is
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT. That is, if you want to do anything with a swap chain image other than operations with it as a color attachment of a render pass instance, or presenting it to the display device, you must first check this bitmask to see if the implementation allows that usage.
vkCmdClearColorImage requires that the image it is given support the
VK_IMAGE_USAGE_TRANSFER_DST_BIT usage. Your implementation clearly does not allow that usage for swap chain images; hence the error.
So you cannot use that command on such swap chain images. You’ll have to clear them the way normal people clear them: as part of the load op for the render pass.