Swiftpack.co - Package - dn-m/MusicXML


Swift Version Platforms Build Status

A work-in-progress implementation of the musicXML specification in Swift.

The goal of this project is to allow Swift users to read, manipulate, and write musicXML files in a richly-typed manner on any platform supported by Swift.


The upcoming pre-release versions will be focused on completing different tasks.


Pre-release version 0.2.0 will be defined by incorporating all of the tests from the full LilyPond Test Suite into the MusicXMLTests target. These tests will be used to ensure that the model is implemented in its entirety, and to soften rough edges in the decoding process of abstract musical content from .xml source files.

The aspiration for this version is to allow an .xml file to be transformed into a data structure capable of feeding an audio engine or to produce a basic musical score.

Attributes defined in attribute groups (e.g., <print-style>, etc.) will not be consistently supported at this point. Likewise, some abstract musical elements may not be decodable due to blocking implementation challenges. These will be documented along with quarantined failing tests.


Pre-release version 0.3.0 will be defined by completing the implementation of the encoding of abstract musical content. The LilyPond Test Suite tests will be transformed into round-trip tests to ensure that the plumbing is clean.


Pre-release version 0.4.0 will be defined by implementing decoding and encoding for attributes defined in attribute groups, which are generally used for graphical information. A standardized way of handling attributes (and attribute groups), elements, values will be chosen and implemented.


Pre-release version 0.5.0 will be defined by refining the public interfaces exposed by the MusicXML package. Up until this point, pubic initializers may be somewhat clumsy or completely non-existent.

Getting Started


Use the Swift Package Manager to include the MusicXML module into your project.


If you want to use the MusicXML module in your own project, add the MusicXML package to the dependencies section of your Package.swift file:

let package = Package(
    name: ...,
    products: [ ... ],
    dependencies: [
        .package(url: "https://github.com/dn-m/MusicXML", from: "0.1.0")
    targets: [ ... ]

Then, import the MusicXML module into a file which uses it:

import MusicXML

You can decode a MusicXML structure in a variety of ways:

let fromData: MusicXML = try MusicXML(data: data)
let fromString: MusicXML = try MusicXML(string: string)
let fromURL: MusicXML = try MusicXML(url: url)


To contribute to the MusicXML package, clone the git repository:

git clone https://github.com/dn-m/MusicXML && cd MusicXML

Build the package:

swift build

Run the tests:

swift test

If you use the Xcode IDE, use the Swift Package Manager to generate an .xcodeproj file:

swift package generate-xcodeproj

See the MusicXML Document Type Definition (DTD) for more information about how musicXML is structured.


Stars: 9
Help us keep the lights on


Used By

Total: 0


0.1.0 - Dec 4, 2018

Provide a model and API for deserializing only the "Hello World" example provided by MakeMusic.