On the competition between dislocation transmission and crack nucleation at phase boundaries