How to use stencil buffer on iOS?

Hi, I’m trying to use stencil buffer across different platforms.

This is the test code below which suppose to be in draw().

ofSetCircleResolution(50);
ofTranslate(100, 100);

glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);

glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

ofSetColor(255, 0, 0);
ofDrawRectRounded(0, 0, 200, 200, 30);

glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

ofSetColor(0, 255, 0);
ofDrawCircle(0, 0, 100);

And this is the image of the result in OSX.

It works as expected on OSX. I had to use “ofGLFWWindowSettings” to create a window and I added
settings.stencilBits = 1; and it all seems to work well.

But on iOS, I don’t know how to set the stencilBits. So without any setting change, if I run the code,
I get this result which is not what I’m expecting.

Can anybody please give me an advice?