DirectoryMonitor is used to monitor the contents of the provided directory by using a GCD dispatch source.
DirectoryMonitor supports multiple methods for installing the library in a project. You can find the latest version in the release tab.
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)
]
)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.
- Create a new
DirectoryMonitor+ specify theURLthat should be monitored - Start monitoring and provide an
EventHandler - 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.
All fame to Apple! This project is based on an example code, ported to Swift 3 and slightly changed.
This project is licensed under the MIT License - see the LICENSE file for details.