hourglass_flowing_sand Schedule is a light-weight task scheduler for Swift. It allows you run timed tasks using an incredibly human-friendly syntax.


  • [x] 🌈 Variety of Rules Schedule
  • [x] πŸ“ Human Readable Period Parse
  • [x] 🚦 Suspend, Resume, Cancel
  • [x] 🎑 Reschedule
  • [x] 🏷 Tag-based Management
  • [x] 🍰 Child-action Add/Remove
  • [x] πŸš” Thread safe
  • [x] 🏌 Full Control Over the Lift Time
  • [x] 🍻 No Need to Worry About Runloop
  • [x] πŸ‘» No Need to Worry About Circular Reference
  • [x] 🍭 Incredibly Human Friendly API

Why should you Use Schedule Instead of Timer?

A chart is worth a thousand words:

Features Timer DispatchSourceTimer Schedule
⏰ Interval-based Schedule βœ“ βœ“ βœ“
πŸ“†Β Date-based Schedule βœ“ βœ“
🌈 Mixing Rules Schedule βœ“
πŸ“ Human Readable Period Parse βœ“
🚦 Suspende/Resume, Cancel βœ“ βœ“
🎑 ReSchedule βœ“ βœ“
🏷 Tag-based management βœ“
🍰 Child-action Add/Remove βœ“
πŸš” Atomic Operations βœ“
πŸš€ Realtime Timeline Inspect βœ“
🏌 Life Time Control βœ“
🍭 Incredibly Human Friendly API βœ“


Scheduling a task can't be simplier:

Schedule.after(3.seconds).do {
    print("3 seconds passed!")

Interval-based Schedule

Schedule.every(1.seconds).do { }

Schedule.after(1.hour, repeating: 1.minute).do { }

Schedule.of(1.second, 2.minutes, 3.hours).do { }

Date-based Schedule { }

Schedule.every(.monday, .tuesday).at("9:00:00").do { }

Schedule.every(.september(30)).at(10, 30).do { }

Schedule.every("one month and ten days").do { }

Schedule.of(date0, date1, date2).do { }

Mixing Rules Schedule

import Schedule

/// concat
let s0 =
let s1 = Schedule.every(1.year)
let birthdaySchedule = s0.concat.s1 { 
    print("Happy birthday")

/// merge
let s3 = Schedule.every(.january(1)).at("8:00")
let s4 = Schedule.every(.october(1)).at("9:00 AM")
let holiday = s3.merge(s4) {
    print("Happy holiday")

/// first
let s5 = Schedule.after(5.seconds).concat(Schedule.every(
let s6 = s5.first(10)

/// until
let s7 = Schedule.every(.monday).at(11, 12)
let s8 = s7.until(date)

Human Readable Period Parse

Schedule.every("one hour and ten minutes").do { }

Schedule.every("1 hour, 5 minutes and 10 seconds").do { }

Task Management

In general, you don't need to worry about reference management of the task any more. All tasks will be retained internally, so they won't be released, unless you do it yourself.

Schedule lets you handle a task's lifecycle with a more elegant way:

Schedule.every(1.second).do(host: self) {
    // do something, and cancel the task when `self` is deallocated.


let task = Schedule.every( { }

task.cancel()    // will remove internally held reference of this task


You can organize tasks with tag, and use queue to define where the task should be dispatched:

let s = Schedule.every(
let task0 = myTaskQueue, tag: "log") { }
let task1 = myTaskQueue, tag: "log") { }


Task.suspend(byTag: "log")
Task.resume(byTag: "log")
Task.cancel(byTag: "log")


Aciton is smaller unit of Task, A task is composed of a series of actions.

let dailyTask = Schedule.every(
dailyTask.addAction {
    print("open eyes")
dailyTask.addAction {
    print("get up")
let key = dailyTask.addAction {
    print("take a shower")
dailyTask.removeAction(byKey: key)


You can get the current timeline of the task:

let timeline = task.timeline

You also can specify task's lifetime:

task.setLifetime(10.hours)  // will cancel this task after 10 hours
task.restOfLifetime == 11.hours


  • Swift 4.x
  • All Apple platforms are supported!
  • And since there is no use of NS class, it should supports linux, too!



# Podfile

target 'YOUR_TARGET_NAME' do
    pod 'Schedule'

Replace YOUR_TARGET_NAME and then run:

$ pod install


Add this to Cartfile

github "jianstm/Schedule"

Then run:

$ carthage update

Swift Package Manager

dependencies: [
    .package(url: "", .upToNextMinor("0.0.0"))

Then run:

$ swift build