# Dispatch source timer not compiling from cli

**URL:** <https://forums.swift.org/t/dispatch-source-timer-not-compiling-from-cli/17562>\
**Category:** Using Swift\
**Tags:** dispatch\
**Created:** [October 31, 2018, 9:31pm UTC](https://forums.swift.org/t/dispatch-source-timer-not-compiling-from-cli/17562 "2018-10-31T21:31:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slucas](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slucas/32/4503_2.png) [@slucas](https://forums.swift.org/u/slucas)\
**Post date:** [October 31, 2018, 9:31pm UTC](https://forums.swift.org/t/dispatch-source-timer-not-compiling-from-cli/17562/1 "2018-10-31T21:31:05Z")

</div>

I've implemented a dispatch source timer that compiles and works on my Mac - but when I compile using the open source toolchain, I get the following error:

Compiler errors:  
…/Sources/supervisor.swift:205:20: error: 'schedule(deadline:repeating:leeway:)' is unavailable  
supervisorTimer?.schedule(deadline: dTimeTillStart, repeating: DispatchTimeInterval.seconds(interval))  
^ ~~~~~~~  
Dispatch.DispatchSourceTimer:15:17: note: 'schedule(deadline:repeating:leeway:)' was introduced in Swift 4  
public func schedule(deadline: DispatchTime, repeating interval: DispatchTimeInterval = default, leeway: DispatchTimeInterval = default)

The compiler note seems to suggest the same function signature as I've used in the code. I'm getting the same failure when I add the third parameter (leeway:). And I've done what I can to verify I'm using the latest toolchain:

Compiler termination message:  
error: terminated(1): /Library/Developer/Toolchains/swift-4.2-RELEASE.xctoolchain/usr/bin/swift-build-tool -f '/Users/scottlucas/Dropbox/personal/Mad Scientist/Swift Development/Fan/Backend/.build/release.yaml' main output:

Output from ‘swift -version’ command:  
Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)  
Target: x86\_64-apple-darwin18.0.0

Here's the relevant code from my project:

Actual code:

```
	supervisorTimer = DispatchSource.makeTimerSource(flags: [], queue: supervisorLoop)
	supervisorTimer?.setEventHandler(handler: self.handler)
	let topOfTheHour = DateComponents(minute: start)
	let startTime = Calendar.current.nextDate(after: Date(), matching: topOfTheHour, matchingPolicy: .nextTime)
	guard
		let timeTillStart = startTime?.timeIntervalSinceNow,
		timeTillStart > 0
		else {fatalError("Failed to start weather check loop. File: \(#file), function: \(#function), line: \(#line)")}
	let dTimeTillStart = DispatchTime.now() + DispatchTimeInterval.seconds(Int(timeTillStart))
	supervisorTimer?.schedule(deadline: dTimeTillStart, repeating: DispatchTimeInterval.seconds(interval))
	supervisorTimer?.resume()

```

Any ideas why the complier's mad about this? I can replace these functions with the older versions (scheduleRepeating and scheduleOneShot) and it'll compile - although Xcode warns the function's deprecated.

Thanks!
