Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 2.35 KB

README.md

File metadata and controls

61 lines (41 loc) · 2.35 KB

Build Status Swift Swift Package Manager compatible Carthage compatible

DirectoryMonitor

DirectoryMonitor is used to monitor the contents of the provided directory by using a GCD dispatch source.

Installation

DirectoryMonitor supports multiple methods for installing the library in a project. You can find the latest version in the release tab.

Installation with Swift Package Manager

To integrate DirectoryMonitor into your Xcode project using Swift Package Manager, specify it in your Package.swift file:

import PackageDescription

let package = Package(
    [...]
    dependencies: [
        .Package(url: "https://github.com/up-n-down/DirectoryMonitor.git", majorVersion: XYZ)
    ]
)

Installation with Carthage

To integrate DirectoryMonitor into your Xcode project using Carthage, specify it in your Cartfile:

github "up-n-down/DirectoryMonitor" ~> X.Y.Z

Run carthage update to build the framework and drag the built DirectoryMonitor.framework into your Xcode project.

Usage

  1. Create a new DirectoryMonitor + specify the URL that should be monitored
  2. Start monitoring and provide an EventHandler
  3. Enjoy your directory changes 🎉
let url = URL(fileURLWithPath: "~/Documents")
let monitor = DirectoryMonitor(at: url)
monitor.startMonitoring {
  print("Directory did change.")
}

You can simply stop monitoring your directory with calling monitor.stopMonitoring(). That's it. It's that simple to use DirectoryMonitor.

Copyright

All fame to Apple! This project is based on an example code, ported to Swift 3 and slightly changed.

License

This project is licensed under the MIT License - see the LICENSE file for details.