Тебе надо таймер в функцию положить. Он не может сам по себе работать так
• Use the scheduledTimer(timeInterval:invocation:repeats:) or scheduledTimer(timeInterval:target:selector:userInfo:repeats:) class method to create the timer and schedule it on the current run loop in the default mode.