Latest 1.2.3
License MIT
Platforms ios 8.0, tvos 9.0, watchos 2.0, osx 10.10, requires ARC

Schedule tasks with constraints made easy.

Carthage compatible
codebeat badge
Swift Package Manager compatible

SwiftQueue is a job scheduler for Ios inspired by popular android libraries like android-priority-jobqueue or android-job. It allows you to run your tasks with run and retry constraints.

Library will rely on Operation and OperationQueue to make sure all tasks will run in order. Don’t forget to check our WIKI.


  • [x] Sequential execution
  • [x] Concurrent run
  • [x] Persistence
  • [x] Cancel all or by tag
  • [x] Delay
  • [x] Deadline
  • [x] Internet constraint
  • [x] Single instance in queue
  • [x] Retry: Max count, exponential backoff
  • [x] Periodic: Max run, interval delay
  • [x] Start / Stop queue


  • iOS 8.0+, watchOS 2.0+, OSX 10.10+, tvOS 9.0+
  • Xcode 7.3



SwiftQueue is carthage compatible. Add the following entry in your Cartfile:

github "lucas34/SwiftQueue"

Then run carthage update.


You can use CocoaPods to install SwiftQueue by adding it to your Podfile:

platform :ios, '8.0'
pod 'SwiftQueue'

In your application, simply import the library

import SwiftQueue

Usage example

This short example will shows you how to schedule a task that send tweets. First, you will need to extend Job and implement onRun, onRetry and onRemove callbacks.

// A job to send a tweet
class SendTweetJob: Job {

    // Type to know which Job to return in job creator
    static let type = "SendTweetJob"
    // Param
    private let tweetMessage: String

    required init(message: String) {
        // Receive params from JobBuilder.with()
        self.tweetMessage = message

    func onRun(callback: JobResult) throws {
        // Run your job here
        callback.onDone(error: nil)

    func onRetry(error: Error) -> RetryConstraint {
        // Check if error is non fatal
        return error is ApiError ? RetryConstraint.cancel : RetryConstraint.retry

    func onRemove(error: Error?) {
        // This job will never run anymore  
        // Success if error is nil. fail otherwise

The class SwiftQueueManager serves as entry point. Your jobs need to extend the class Job. Specify run and retry constraints with JobBuilder and schedule by giving SwiftQueueManager

let manager = SwiftQueueManager(creators: [TweetJobCreator()])

Schedule a job with type, parameters and constraints.

JobBuilder(type: SendTweetJob.type)
        // params of my job
        .with(params: "Hello TweetWorld")
        // Add to queue manager
        .schedule(manager: manager)

The JobCreator maps a job type to a specific job class. You will receive parameters you specified in JobBuilder.

class TweetJobCreator: JobCreator {

    // Base on type, return the actual job implementation
    func create(type: String, params: Any?) -> Job? {
        // check for job and params type
        if type == SendTweetJob.type, let message = params as? String  {
            return SendTweetJob(message: message)
        } else {
            // Nothing match
            return nil

That’s it. We haven’t specify any constraint so the job will run immediately. Check the WIKI for a more detailed example.


We would love you for the contribution to SwiftQueue, check the LICENSE file for more info.


Distributed under the MIT license. See LICENSE for more information.

Latest podspec

    "name": "SwiftQueue",
    "version": "1.2.3",
    "summary": "SwiftQueue",
    "description": "Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Lucas Nelaupe": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.2.3"
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0",
        "watchos": "2.0",
        "osx": "10.10"
    "requires_arc": true,
    "source_files": "Sources/SwiftQueue/**.swift",
    "ios": {
        "dependencies": {
            "ReachabilitySwift": [
                "~> 4.1"
    "tvos": {
        "dependencies": {
            "ReachabilitySwift": [
                "~> 4.1"
    "osx": {
        "dependencies": {
            "ReachabilitySwift": [
                "~> 4.1"
    "pushed_with_swift_version": "4.0"

Pin It on Pinterest

Share This