{"id":17630226,"url":"https://github.com/giannicarlo/directorywatcher","last_synced_at":"2025-05-01T12:52:02.681Z","repository":{"id":52186486,"uuid":"141661000","full_name":"GianniCarlo/DirectoryWatcher","owner":"GianniCarlo","description":"LIstener for changes in a specified folder","archived":false,"fork":false,"pushed_at":"2021-06-20T18:26:51.000Z","size":39,"stargazers_count":50,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T12:51:44.029Z","etag":null,"topics":["gcd","ios","listener","swift","watcher"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GianniCarlo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-20T03:51:22.000Z","updated_at":"2025-02-21T07:01:27.000Z","dependencies_parsed_at":"2022-08-20T19:50:29.760Z","dependency_job_id":null,"html_url":"https://github.com/GianniCarlo/DirectoryWatcher","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianniCarlo%2FDirectoryWatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianniCarlo%2FDirectoryWatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianniCarlo%2FDirectoryWatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GianniCarlo%2FDirectoryWatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GianniCarlo","download_url":"https://codeload.github.com/GianniCarlo/DirectoryWatcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251879122,"owners_count":21658691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gcd","ios","listener","swift","watcher"],"created_at":"2024-10-23T00:53:13.681Z","updated_at":"2025-05-01T12:52:02.639Z","avatar_url":"https://github.com/GianniCarlo.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a Swift translation of the [Objective C version](https://github.com/hwaxxer/MHWDirectoryWatcher). Took some inspiration from [this repo](https://github.com/dagostini/DAFileMonitor/tree/blog_dispatch_sources) as well\n\n# DirectoryWatcher\n`DirectoryWatcher` is a lightweight class that uses GCD to monitor a given path for changes.\nWhen any change to the directory occurs, `DirectoryWatcher` starts polling the monitored path, making sure that file transfers are finished before posting notifications.\n\n## Installing\n\n### [CocoaPods](https://cocoapods.org/) (recommended)\n\n````ruby\n# For latest release in cocoapods\npod 'DirectoryWatcher'\n````\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](https://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate DirectoryWatcher into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"GianniCarlo/DirectoryWatcher\" ~\u003e 2.0.0\n```\n\nRun `carthage update` to build the framework and drag the built `DirectoryWatcher.framework` into your Xcode project.\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\n\nOnce you have your Swift package set up, adding DirectoryWatcher as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n\t.package(url: \"https://github.com/GianniCarlo/DirectoryWatcher.git\", .upToNextMajor(from: \"2.7.0\"))\n]\n```\n\n## Usage (DirectoryWatcher)\n\nMonitor the Documents Folder\n\n```swift\nlet documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!\nlet watcher = DirectoryWatcher.watch(documentsUrl)\n\nwatcher.onNewFiles = { newFiles in\n  // Files have been added\n}\n\nwatcher.onDeletedFiles = { deletedFiles in\n  // Files have been deleted\n}\n```\nCall `watcher.stopWatching()` and `watcher.startWatching()` to pause / resume.\n\n## Usage (DirectoryDeepWatcher)\n\nMonitor the Documents Folder and its subfolders\n\n```swift\nlet documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!\nlet watcher = DirectoryDeepWatcher.watch(documentsUrl)\n\nwatcher.onFolderNotification = { folder in\n  // New changes have happened inside one folder\n  // This folder could be a subfolder inside the root folder being watched\n}\n\n```\n\n\nCall `watcher.stopWatching()` and `watcher.startWatching()` to pause / resume, or `watcher.restartWatching()` to discard previous listeners and place new ones in case the hierarchy has changed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiannicarlo%2Fdirectorywatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiannicarlo%2Fdirectorywatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiannicarlo%2Fdirectorywatcher/lists"}