It helps to position the nose of the car as close as possible to directly under the opener. To do this, I had to pull my opener's emergency release latch to be able to program my opener without closing the door on the car.
The reason for this is that the garage door opener massively reduces its receiver sensitivity while in learn mode. This is done to make sure that the opener can only be taught the intended code, not your neighbor's when they open their garage door while yours is in learn mode.
Many times this step will work with the car several feet away from the opener, depending on details of hardware and luck. But It didn't work for my Air, nor for my brother in law's Macan. In both cases I had to use the opener's emergency release and position the nose of the car directly under the opener. This worked perfectly on first try.