ControlKit is a minimal Swift Package enabling control of media playback and device volume.
Control the device's volume with one line:
Control.Volume.increase() // 🔊 🆙
Add ControlKit as a dependency in your Xcode project:
-
Go to File > Add Package Dependencies…
-
Enter the package URL in the search bar:
https://github.com/superturboryan/ControlKit.git
- Choose the libraries you want to include:
SpotifyController
requires a Spotify Client ID
and Redirect URL to authorize with & control the Spotify app.
-
Define a custom URL scheme for your app. Add a
URL Type
to the target'sInfo.plist
. -
Create an app in the Spotify Developer Dashboard to get a client ID and register your redirect URL (scheme).

The Spotify access token is not persisted across app launches by default.
You must provide an object conforming to DAO<String>
if you want the access token to be persisted.
import Control
// 🔊 Decrement system volume
Control.Volume.decrease()
// 🕵️♂️ Check if audio is being played (by another app)
if Control.Playback.isAudioPlaying {
// 💃🕺
}
// ⏭️ Skip to next track (Apple Music only - use Controllers.SpotifyController for Spotify 💚)
Control.Playback.AppleMusic.skipToNextTrack()
// 🫨 Vibrate
Control.Haptics.vibrate()
// App.swift
import Controllers
import SwiftUI
@main struct YourApp: App {
@StateObject var spotify = SpotifyController(
config: .init(
clientID: Secrets.clientID,
redirectURL: "controlkit://spotify"
)
)
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(spotify)
.onOpenURL { spotify.setAccessToken(from: $0) } // Parse access token from URL
}
}
func skipToNextSpotifyTrack() {
spotify.skipToNextTrack()
}
}
// Secrets.swift 🔐
// Don't forget to gitignore this 🙈
enum Secrets {
static let clientID = "<your client id>"
}
📚 AVFAudio
📚 Media Player
📦 SpotifyiOS
Contributions and feedback are welcome! 🧑💻👩💻
Here are a few guidelines:
- You can open an Issue or raise a PR 🤝
- Commit messages should contain emojis ❤️ and be signed 🔏
- Workflows should be green 🟢
main
should be linear 🎋