Latest 0.4.3
License MIT
Platforms ios 9.0

Build Status codecov CocoaPod Version

A cron expression parser that can take a cron string and give you the next run date and time specified in the string. SwiftCron can be used on iOS 9.0 and above.

SwiftCron was built for use in an upcoming project for Prolific Idea. You can find them on Github, Twitter, or their website.



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.0.0+ is required to build SwiftCron.

To integrate SwiftCron into your Xcode project using CocoaPods, specify it in your Podfile:

source ''
platform :ios, '9.0'

pod 'SwiftCron'

Then, run the following command:

$ pod install

How to

Create a Cron Expression

Creating a cron expression is easy. Just invoke the initializer with the fields you want.

// Midnight every 8th day of the month
let myCronExpression = CronExpression(minute: "0", hour: "0", day: "8")
// Executes May 9th, 2024 at 11:30am
let anotherExpression = CronExpression(minute: "30", hour: "11", day: "9", month: "5", year: "2024") 
// Every tuesday at 6:00pm
let everyTuesday = CronExpression(minute: "0", hour: "18", weekday: "3")

Manually create an expression

If you’d like to manually write the expression yourself, The cron format is as follows:

* * * * * *

(Minute) (Hour) (Day) (Month) (Weekday) (Year)

Initialize an instance of CronExpression with a string specifying the format.

// Every 11th May at midnight
let every11May = CronExpression(cronString: "0 0 11 5 * *")

Get the next run date

Once you have your CronExpression, you can get the next time the cron will run. Call the getNextRunDate(_:) method and pass in the date to begin the search on.

// Every Friday 13th at midday
let myCronExpression = CronExpression(minute: "0", hour: "12", day: "13", weekday: "5")

let dateToStartSearchOn = NSDate()
let nextRunDate = myCronExpression.getNextRunDate(dateToStartSearchOn)


  • iOS 9.0 or greater
  • Xcode 8.0 or greater
  • Swift 3 or greater

Latest podspec

    "name": "SwiftCron",
    "version": "0.4.3",
    "summary": "Cron expression parser.",
    "description": "A cron expression parser written in Swift that can take a cron string and give you the next run date and time specified in the string.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Keegan Rush": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.4.3"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source_files": "Sources/**/*",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This