How to reduce image bit-depth (Quantization) with Swift?

is there a way on iPhone to reduce image bit-depth. I'm trying to reduce the image size to less than 1 MB but I don't want change the image width and height. so reducing the image resolution might be the correct way to do that. Anyone know how to do that using swift?