From 2ae8f13da4fd2291514272047b0521d15d379edb Mon Sep 17 00:00:00 2001 From: Ryan Collins Date: Thu, 30 Mar 2017 11:33:47 -0400 Subject: [PATCH] Updated Readme Removed RunLoop Requirement --- README.md | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/README.md b/README.md index b4a2e7b..a9e4efe 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ Welcome! This project will hopefully help you run scheduled and repeating functions in Swift! This is a very basic start to having a robust cron application in pure Swift. There is still a lot of work to be done. Pull requests are encouraged and welcomed... 😃 -### IMPORTANT NOTE FOR UBUNTU USERS -Right now this library uses NSTimer and, thus #selector and needs the objective-c runtime, so it only works on macOS. I am looking into other ways to accomplish this, but until then you're stuck with macOS. - ## Setup To Add Cron to your Project, you first need to add this repository as a dependency in Package.swift: @@ -40,17 +37,12 @@ let package = Package( ## Usage -### Required Executable - -Your main.swift will need some boilerplate code. You can grab this from the example repository, but you will need an absolute minimum of: +Needs a minimum of: ``` import Foundation import SwiftCron -var shouldKeepRunning = true // change this `false` to stop the application from running -let theRL = RunLoop.current // Need a reference to the current run loop - // Welcome to Cron! // If you add frequency: X to the intializer here, cron will attempt to run your jobs every X seconds // If you do not add a frequency, it defaults to 60 (every minute) @@ -68,10 +60,6 @@ cron.add(job) //Start Cron So the Jobs Run cron.start() - -//Start and Keep Running the Run Loop -while shouldKeepRunning && theRL.run(mode: .defaultRunLoopMode, before: .distantFuture) { } - ``` Everything should go in the order it is in the example. You may also import functions from another Framework or write your own inside new files in your project. Cron will accept any valid functions that have no return and no parameters. @@ -120,15 +108,4 @@ After defining jobs, `cron.add(job)` will add that job to cron. You can also cal `cron.start()` will start the Cron machine running, thus running any jobs added, assuming they're beyond their `executeAfter:` Date. -#### Keeping it all Running - -Last, but certainly not least is: - -``` -//Start and Keep Running the Run Loop -while shouldKeepRunning && theRL.run(mode: .defaultRunLoopMode, before: .distantFuture) { } -``` - -This **MUST** be at the **END** of main.swift, because it keeps the application running. Without this line at the end, the application would simply terminate on launch. - Hopefully there is more to come. For now, please enjoy. \ No newline at end of file