I will sell my apartment abroad in 2017. I will pay taxes abroad for it. Can I take tax credit here in April 2018 if my foreign taxes are also paid in early 2018?

I am asking because Form 1116 seems to assume that I will pay foreign taxes the same year when I sell the apartment, in 2017.