Theory of defect-mediated morphogenesis