I'm going to be a crazy one and say that my story actually determines what sex I pick for the main character. I love putting my characters through hell, I'm pretty sadistic with storylines, and depending on the story I try to find which one would be more of a challenge for which sex, if it's relevant.
For the most part I like a Miyazaki look on it and believe that all challenges make it equal, but if I'm writing about the Middle Ages or a society where women are oppressed, then I tend to lean on female leads. I like to write about male leads if they're conflicting with masculinity and trying to fight the mold laid out that men should be physically strong, decisive, etc. but for the most part I find it easier to write about girls for obvious reasons.
For side characters, I try to find who complements the main character the most. I like contrast here, similarities there, etc. Honestly I don't think that's a good way to really decide side characters, but it's how I do it.
And for writing with anonymity of the protagonist's sex, use "they" instead of "he/she?" I really don't know how that one would work out.