A guitar chord diagram drawing library built in Swift

A guitar chord diagram drawing library built in Swift

This is a Swift library that can generate CAShapeLayers for any chord within it's database.

Swifty Guitar Chords

This is a Swift library that can generate CAShapeLayers for any chord within it's database. All you need to do is supply a Key (C, C#, etc) and a suffix (Major, Minor, sus4, etc) to find the appropriate chord. Each chord comes with a few variants.

The database is pulled from another project I found a while ago, but cannot remember where that was. Please do not rely 100% on this data, as I have found that a few chords are incorrect. If you find any of your own, please open a PR correcting these.

This library is currently in Beta. Everything works, and the drawing speeds are fine, but there is lots of room for improvement.

I am using this library in my music study app "Mustud" with no problems at all.


  • iOS 13+
  • Xcode 11+


Only supports Swift Package Manager at this time.


Get all Chords
Filter by Key

Returns all chords based on C

GuitarChords.all.matching(key: .c)
Filter by Suffix

Returns all major chords in the database.

GuitarChords.all.matching(suffix: .major)
Filter by Key and Suffix

Returns all CMajor chords.

These will be in order of position on the fretboard, starting at the nut.

GuitarChords.all.matching(key: .c).matching(suffix: .major)


There are a number of ways to use the CAShapeLayer. You can add it directly to a view, or convert it to a UIImage.

Image from layer extension is as follows, and is not present in the library:

extension CALayer {

    func imageFromLayer() -> UIImage? {
        UIGraphicsBeginImageContextWithOptions(self.frame.size, self.isOpaque, 0)

        defer { UIGraphicsEndImageContext() }

        guard let context = UIGraphicsGetCurrentContext() else {
          return nil

        self.render(in: context)
        return UIGraphicsGetImageFromCurrentImageContext()


To use it, we just need a chord!

let chordPosition = GuitarChords.all.matching(key: .c).matching(suffix: .major).first!
let frame = CGRect(x: 0, y: 0, width: 100, height: 150)
let layer = chordPosition.layer(rect: frame, showFingers: true, showChordName: true, forScreen: true)
imageView.image = layer?.imageFromLayer()


frame is the size of the shape layer. The size of your chord.

showFingers set this to true if you want the finger positions to be drawn on each note.

showChordName set this to true if you want the chord name displayed. You may want to hide this if you were building a flashcard or chord quiz app.

forScreen This is for dark mode support. Set it to false if you want it to always be drawn with a white background and black text (ideal for printing).


drawing swift mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How To Succeed In Mobile App Wireframe Design?

This article covers everything about mobile app wireframe design: what to do and what not, tools used in designing a mobile or web app wireframe, and more.

Top 10 Mobile App Development Companies in India

The mobile application scenario has been continually changing over the years. In recent years India has become a center for mobile app development companies. The increase of smartphones has instantly increased the requirements for these apps. Every year new technological trends occur due to contin

Best Swift App Development Company

Apple Swift App Development India: Mobile App Development India is an expert iOS Swift App Development company in India. We develop secure and robust mobile app solutions based on new Apple Swift language.

Top Swift iOS App Development Company in USA

AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!

Hire Mobile App Developers in USA

AppClues Infotech is the best mobile app development company in New York that offers custom mobile app development & design services for Android and iOS.