Are `sh` and `x` really different phonemes, or just different realizations of the same phoneme? I can't think of any minimal pairs; like shu vs. xu probably shouldn't count as a minimal pair since the vowel is different.
This is a classic problem with defining phonemes. Looking for &quot;complementary distribution&quot; of sounds does not uniquely determine a phonological analysis. In Mandarin (I'll use pinyin here), the palatal set of consonants (j,q,x) is in complementary distribution with all of the following sets:

zh, ch, sh
z, c, s
g, k, h

This gives you three different options on which things to treat as the &quot;same&quot; phonemes. And you can go in the opposite direction too: Pinyin distinguishes all these consonant-sets, but then it merges the written form of the front-vs-back vowels. You could do a phonological analysis like that too, or at least, you almost could, as /u/ and /y/ contrast when following /n/ and /l/.
And indeed it's the case that different romanization systems make different choices about how to do this. To quote from Wikipedia:

The Yale and Wade–Giles systems mostly treat the palatals as allophones of the retroflexes; Tongyong Pinyin mostly treats them as allophones of the dentals; and Mainland Chinese Braille treats them as allophones of the velars. In standard pinyin and bopomofo, however, they are represented as a separate sequence.
The palatals arose historically from a merger of the dentals [t͡s, t͡sʰ, s] and velars [k, kʰ, x] before high front vowels and glides. Previously, some instances of modern [t͡ɕ(ʰ)i] were instead [k(ʰ)i], and others were [t͡s(ʰ)i] . The change took place in the last two or three centuries at different times in different areas, but not in the Jianghuai dialect used at the imperial court. This explains why some European transcriptions of Chinese names (especially in postal romanization) contain ki-, hi-, tsi- or si- where a palatal might be expected. Examples are Peking for Beijing, Chungking for Chongqing, Fukien for Fujian, Tientsin for Tianjin; Sinkiang for Xinjiang, and Sian for Xi'an.