XYZ spectroscopy at electron-hadron facilities. II. Semi-inclusive processes with pion exchange