Latest 0.1.2
License MIT
Platforms ios 8.0

Build Status

DirectoryObserver is a microlibrary for monitoring directory changes using GCD.




  1. Add the pod DirectoryObserver to your Podfile.
    pod 'DirectoryObserver'
  2. Run pod install from Terminal, then open your app’s .xcworkspace file to launch Xcode.


  1. Download the source files in the DirectoryObserver subdirectory.
  2. Add the source files to your Xcode project.

How to use

Get an instance of DirectoryObserver by either instantiation or using the extension method on NSURL:

  • DirectoryObserver(pathToWatch: NSURL, completion: () -> Void) -> DirectoryObserver
  • NSURL.setupObserver() -> DirectoryObserver

The completion closure will be called when changes are detected and have completed.

let fileManager = NSFileManager.defaultManager()
let directory = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first!

directoryWatcher = DirectoryObserver(pathToWatch: directory) {
    print("Directory contents have changed")

// added method on `NSURL` directly -- equivalent to example above
directoryWatcher = directory.setupObserver() {
    print("Directory contents have changed")

You may then use the startObserving() or stopObserving() methods to stop/start/resume observing.

DirectoryObserver is a Swift port of MHWDirectoryWatcher

Latest podspec

    "name": "DirectoryObserver",
    "version": "0.1.2",
    "summary": "A microlibrary for monitoring directory changes",
    "description": "A microlibrary for monitoring directory changes using GCD.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "David Chavez": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.2"
    "platforms": {
        "ios": "8.0"
    "source_files": "DirectoryObserver/Classes/**/*"

Pin It on Pinterest

Share This