During the design of a hadron linac, matching at the interfaces of different structures or lattice periods is often performed with the linear approximation of the space-charge force. When space-charge is extremely strong, like in the low energy part of the proton linac of the European Spallation Source, such a matching method is not always good enough and could lead to a residual mismatch at the design level. To avoid this, a matching scheme based on iterations of tracking, thus including the full effect of the space-charge force, is developed. This paper presents the scheme itself as well as its application to the ESS linac.