{"id":24064376,"url":"https://github.com/perseusrealdeal/perseusdarkmode","last_synced_at":"2026-03-15T17:04:23.192Z","repository":{"id":37495985,"uuid":"463086784","full_name":"perseusrealdeal/PerseusDarkMode","owner":"perseusrealdeal","description":"Swift Dark Mode lib. macOS 10.9+, iOS 9.3+, Xcode 10.1+.","archived":false,"fork":false,"pushed_at":"2025-04-22T07:45:28.000Z","size":347,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T07:50:31.729Z","etag":null,"topics":["apple","carthage","cocoa","cocoapods","dark-mode","ios","ios-swift","macos","macos-swift","package","standalone","swift","swift-package-manager","uikit"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/perseusrealdeal.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-02-24T09:33:39.000Z","updated_at":"2024-10-20T06:03:24.000Z","dependencies_parsed_at":"2024-10-29T06:20:46.251Z","dependency_job_id":"406cbe1b-0b85-4230-b0b4-a934d3c7e981","html_url":"https://github.com/perseusrealdeal/PerseusDarkMode","commit_stats":{"total_commits":200,"total_committers":3,"mean_commits":66.66666666666667,"dds":0.565,"last_synced_commit":"1db4f3fa9089e96707d5a60889c2738b4c81dfdd"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FPerseusDarkMode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FPerseusDarkMode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FPerseusDarkMode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FPerseusDarkMode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perseusrealdeal","download_url":"https://codeload.github.com/perseusrealdeal/PerseusDarkMode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250493632,"owners_count":21439813,"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":["apple","carthage","cocoa","cocoapods","dark-mode","ios","ios-swift","macos","macos-swift","package","standalone","swift","swift-package-manager","uikit"],"created_at":"2025-01-09T10:24:56.942Z","updated_at":"2026-03-15T17:04:23.138Z","avatar_url":"https://github.com/perseusrealdeal.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Perseus Dark Mode\n\n[![Actions Status](https://github.com/perseusrealdeal/DarkMode/actions/workflows/main.yml/badge.svg)](https://github.com/perseusrealdeal/PerseusDarkMode/actions)\n![Version](https://img.shields.io/badge/Version-1.1.5-informational.svg)\n[![Pod](https://img.shields.io/badge/Pod-1.1.4-informational.svg)](/PerseusDarkMode.podspec)\n![Platforms](https://img.shields.io/badge/Platforms-iOS%209.3+,%20macOS%2010.9+-orange.svg)\n[![Swift 4.2](https://img.shields.io/badge/Swift-4.2-red.svg)](https://docs.swift.org/swift-book/RevisionHistory/RevisionHistory.html)\n[![License](http://img.shields.io/:License-MIT-blue.svg)](/LICENSE)\n\n## Integration Capabilities\n\n[![Standalone](https://img.shields.io/badge/Standalone-available-informational.svg)](/PerseusDarkModeSingle.swift)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage)\n[![CocoaPods manager](https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg)](/PerseusDarkMode.podspec)\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg)](/Package.swift)\n\n## Demo Apps and Others\n\n[![Demo App](https://img.shields.io/badge/iOS%20Demo%20App-available-yellow.svg)](https://github.com/perseusrealdeal/ios.darkmode.discovery.git)\n[![Demo App](https://img.shields.io/badge/macOS%20Demo%20App-available-yellow.svg)](https://github.com/perseusrealdeal/macos.darkmode.discovery.git)\n[![PerseusUISystemKit](http://img.shields.io/:Satellite-PerseusUISystemKit-blue.svg)](https://github.com/perseusrealdeal/PerseusUISystemKit.git)\n[![XcodeTemplateProject](http://img.shields.io/:Template-XcodeTemplateProject-blue.svg)](https://github.com/perseusrealdeal/XcodeTemplateProject.git)\n\n# In Brief\n\n\u003e This library lets a developer being awared of Dark Mode via a variable `DarkMode.style`. Also, with this library it is possible to change the value of Dark Mode in runtime easily with standalone lib [DarkModeSwitching](https://gist.github.com/perseusrealdeal/11b1bab47f13134832b859f49d9af706).\n\n```swift\nchangeDarkModeManually(.off) // .on or .auto\n```\nSample screen for changing Dark Mode option [here for macOS](https://github.com/perseusrealdeal/macos.darkmode.discovery) and [here for iOS](https://github.com/perseusrealdeal/ios.darkmode.discovery).\n\n# Reqirements\n\n- Xcode 10.1+\n- Swift 4.2+\n- iOS: 9.3+, UIKit SDK\n- macOS: 10.9+, AppKit SDK\n\n# First-party software\n\n- [PerseusLogger](https://gist.github.com/perseusrealdeal/df456a9825fcface44eca738056eb6d5)\n\n# Third-party software\n\n- [SwiftLint Shell Script Runner](/SucceedsPostAction.sh)\n- [SwiftLint](https://github.com/realm/SwiftLint) / [0.31.0: Busy Laundromat](https://github.com/realm/SwiftLint/releases/tag/0.31.0) for macOS High Sierra\n\n# Installation\n\n\u003e ***Using \"Exact\" with the Version field is strongly recommended.***\n\n## Step 1: Add PerseusDarkMode to a host project tree\n\n### Standalone \n\nMake a copy of the file [`PerseusDarkModeSingle.swift`](/PerseusDarkModeSingle.swift) then put it into a place required of a host project.\n\n### Carthage\n\nCartfile should contain:\n\n```carthage\ngithub \"perseusrealdeal/PerseusDarkMode\" == 1.1.5\n```\n\nSome Carthage usage tips placed [here](https://gist.github.com/perseusrealdeal/8951b10f4330325df6347aaaa79d3cf2).\n\n### CocoaPods\n\nPodfile should contain:\n\n```ruby\ntarget \"ProjectTarget\" do\n  use_frameworks!\n  pod 'PerseusDarkMode', '1.1.4'\nend\n```\n\n### Swift Package Manager\n\n- As a package dependency so Package.swift should contain the following statements:\n\n```swift\ndependencies: [\n        .package(url: \"https://github.com/perseusrealdeal/PerseusDarkMode.git\",\n            .exact(\"1.1.5\"))\n    ],\n```\n\n- As an Xcode project dependency: \n\n`Project in the Navigator \u003e Package Dependencies \u003e Add Package Dependency`\n\n\u003e ***Using \"Exact\" with the Version field is strongly recommended.***\n\n## Step 2: Make DarkMode ready for using\n\n### iOS\n\nOverride the following method of the first screen to let Perseus know that system's appearance changed:\n\n```swift\nclass MainViewController: UIViewController {\n    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {\n        super.traitCollectionDidChange(previousTraitCollection)\n\n        if #available(iOS 13.0, *) {\n            AppearanceService.processTraitCollectionDidChange(previousTraitCollection)\n        }\n    }\n}\n```\n\nAlso, if Dark Mode is released with Settings bundle put the statements into the app's delegate:\n\n```swift\nextension AppDelegate: UIApplicationDelegate {\n\n    func applicationDidBecomeActive(_ application: UIApplication) {\n\n        // Update Dark Mode from Settings\n        if let choice = isDarkModeSettingsChanged() {\n            // Change Dark Mode value in Perseus Dark Mode library\n            AppearanceService.DarkModeUserChoice = choice\n            // Update appearance in accoring with changed Dark Mode Style\n            AppearanceService.makeUp()\n        }\n    }\n}\n```\nUsed functions are distributed via standalone file [`DarkModeSwitching.swift`](https://gist.github.com/perseusrealdeal/11b1bab47f13134832b859f49d9af706).\n\n### iOS and macOS\n\nCall the method `AppearanceService.makeUp()` with the app's delegate if appearance changing is going to take place:\n\n```swift\nextension AppDelegate: UIApplicationDelegate {\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions\n        launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\n        \n        // ... code\n        \n        // Call AppearanceService.makeUp() method if AppearanceService.register(:, :)\n        // is taken into account\n        AppearanceService.makeUp()\n\n        // ... otherwise call AppearanceService.recalculateStyleIfNeeded()\n        // to load DarkMode.style from user defaults\n        // AppearanceService.recalculateStyleIfNeeded()\n    }\n}\n```\nCopy the file [`DarkModeSwitching.swift`](https://gist.github.com/perseusrealdeal/11b1bab47f13134832b859f49d9af706) into a host project for having fun with manual changing Dark Mode value.\n\n# Usage\n\nEach time if Dark Mode changed the mentioned method `#selector(makeUp)` called, but registering is required:\n```swift\nclass MainViewController: UIViewController {\n\n    // At any view controller where changing is required\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        AppearanceService.register(stakeholder: self, selector: #selector(makeUp))\n    }\n\n    @objc private func makeUp() {\n        print(\"^_^ \\(AppearanceService.DarkModeUserChoice)\"\n\n        switch DarkMode.style {\n        case .light:\n            // make drawings for light mode\n            break\n        case .dark:\n            // make drawings for dark mode\n            break\n        }\n    }\n}\n```\n\nThere is another way to be notified of Dark Mode—KVO. \n\n\u003e [`DarkModeImageView`](https://github.com/perseusrealdeal/PerseusUISystemKit/blob/master/Sources/PerseusUISystemKit/Classes/DarkModeImageView.swift) class is an expressive sample of Dark Mode KVO usage for both macOS and iOS as well.\n\n# License MIT\n\nCopyright © 7530 - 7531 Mikhail Zhigulin of Novosibirsk.\n\n- The year starts from the creation of the world according to a Slavic calendar.\n- September, the 1st of Slavic year.\n\n[LICENSE](/LICENSE) for details.\n\n# Author\n\n\u003e `PerseusDarkMode` was written at Novosibirsk by Mikhail Zhigulin i.e. me, mzhigulin@gmail.com.\n\n\u003e Mostly I'd like thank my lovely parents for supporting me in all my ways.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperseusrealdeal%2Fperseusdarkmode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperseusrealdeal%2Fperseusdarkmode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperseusrealdeal%2Fperseusdarkmode/lists"}