RSMetronome is an library written in Swift that can be used to implement a basic metronome.
let metronome = Metronome()
metronome.start()
metronome.stop()
metronome.settings.tempo = 60
The TapTempo class can help you determine a tempo by averaging the time between a number of taps on a button.
let tapTempo = TapTempo(samples: 3)
tapTempo.tap()
// Wait
tapTempo.tap()
// Wait
let tempo = tapTempo.tap()