Latest 0.0.4
License MIT
Platforms osx 10.10, requires ARC
Frameworks CoreServices


Hoon H.

Provides dead-simple access to FSEvents framework for Swift.
Low level core is written in Objective-C due to lack of support from Swift.
(lacks some flags, lacks C-callback function)

How To Use

First, you need to add this framework to your Xcode project.
If you’re not sure how to add this framework to your existing Xcode project, please see this
video posting.

Here’s a minimal example code which waits for events and prints them. This single statement
does everything all needed jobs to setup. Just keep the created object as long as you want
to receive the events.

    import Cocoa
    import EonilFileSystemEvents

    class AppDelegate: NSObject, NSApplicationDelegate {

        @IBOutlet weak var window: NSWindow!

        let s1 = FileSystemEventMonitor(
            pathsToWatch: [
            latency: 1,
            watchRoot: true,
            queue: dispatch_get_main_queue()) { (events: [FileSystemEvent])->() in

If you want to stop monitoring, just remove all the strong references.

    var m: FileSystemEventMonitor? = FileSystemEventMonitor( /* arguments omitted */ )
    // Now it started.

    m = nil 
    // Now it stopped. Because it's dead. 

Please take care that object reference can be shared in Swift, so you need to ensure no
other object to reference the monitor object. If you’re not familiar with reference-counting,
please see this: Automatic Reference Counting

See TestdriveApp target for another fully fledged Swift example. The example app starts
monitoring when it becomes active, and stops monitoring when it becomes inactive. Try it!


Use FileSystemEventMonitor class. Required informations are
all noted as comments.
Create it, and monitoring will start immediately. Deallocate it to
stop monitoring. (RAII semantics) Supplied callback block will be
notified on specified event.

Unfortunately, as Swift does not support static library target, you
cannot link this as a library to a command-line programs currently.
So examples had to written as an AppKit application target.

For Objective-C programs, use EonilFileSystemEventStream class.
Required informations are all noted as comments. This class follows
strict Objective-C conventions, so should be straightforward.
It is unclear how long I will keep the Objective-C version.


This library requires macOS 10.10 to run and Xcode 8.0 to build.


This library is written by Hoon H. and licensed under "MIT License".

Latest podspec

    "name": "EonilFileSystemEvents",
    "version": "0.0.4",
    "summary": "Dead-simple access to FSEvents framework for Swift.",
    "description": "Provides dead-simple access to FSEvents framework for Swift by Hoon H.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": "Hoon H",
    "frameworks": "CoreServices",
    "requires_arc": true,
    "platforms": {
        "osx": "10.10"
    "source": {
        "git": "",
        "tag": "0.0.4"
    "source_files": [

Pin It on Pinterest

Share This