Skip to content

GianniCarlo/Themeable

 
 

Repository files navigation

Themeable

Themeable provides easy to setup theme management in your app. It doesn't use NotificationCenter.

Requirements

  • Swift 6.0+
  • iOS 13.0+ / macOS 11.0+
  • Xcode 16.0+

Installing

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Themeable as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
	.package(url: "https://github.com/GianniCarlo/Themeable.git", .upToNextMajor(from: "3.0.0"))
]

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "GianniCarlo/Themeable" ~> 3.0.0

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

Migration from 1.x

Version 3.0.0 adopts Swift 6 strict concurrency. All core types (ThemeProvider, Themeable, Theme, SubscribableValue) are now @MainActor-isolated.

What you need to change:

  • Your ThemeProvider implementation must be @MainActor (or already inherit it, e.g. from a UIViewController)
  • If you were accessing Theme properties from a background thread, wrap the access in MainActor.run { ... }

What stays the same:

  • All method signatures are unchanged
  • Theme is still an open class — subclassing works as before
  • setUpTheming() called from viewDidLoad() works without changes (UIViewControllers are already @MainActor)

Usage

  • Provide a theme manager that conforms to the protocol ThemeProvider.
  • Any object that you want to react to the change of the new theme, should conform to the protocol Themeable

Packages

 
 
 

Contributors

Languages

  • Swift 97.8%
  • Objective-C 2.2%