Create custom CGColorSpaceRef profile

Hello.
I need to create a matrix based ICC profile in my app. I provide everything - matrix, illuminant and so on. I have code which does that with ColorSync on macOS and profile works fine. Now I'd like to do the same and seems like Core Image has CGColorSpaceCreateCalibratedRGB(), which appears to be something close, but profile it creates is not correct. Specifically value Y in gXYZ and bXYZ tags seem to be clamped. F.e. in gXYZ Y should be 1.061, but CI gives me 1.000, bXYZ Y should be -0.239 and CI gives me 0.000.
Also it gives me different class (Display and I need Device). Basically produced profile is not working. Is there other way which would allow me to create a custom matrix device profile on iPadOS/iOS?
Thanks!
Create custom CGColorSpaceRef profile
 
 
Q