A library to read and write Metadata in audio files.
Built on top of taglib v2.1.
Heavily inspired by SFBAudioEngine and made as an adaptation of it with focus on metadata.
You can review differences from SFBAudioEngine here.
import SwiftTagLib
// create audio file from url: reads it's metadata & properties
let url = URL(fileURLWithPath: "./path/to/audiofile.mp3")
var audioFile = try AudioFile(url: url)
// by default attached pictures are read from metadata during initialization
// skipping them will reduce time spent reading metadata
audioFile = try AudioFile(url: url, options: [.skipPictures])
// if you need to know if file metadata has attached pictures,
// might give false positives if pictures are corrupted/empty
print("has attached pictures:", audioFile.metadata.hasAttachedPictures)
// get metadata values
print("song:", audioFile.metadata.artist ?? "_", "-", audioFile.metadata.title ?? "_")
print("bitrate:", audioFile.properties.bitrate, "duration:", aduioFile.properties.duration)
let picture = audioFile.metadata.attachedPictures.first
// set metadata values
audioFile.metadata.title = "Song name"
audioFile.metadata.lyrics = .none
audioFile.metadata.attachedPictures = [
.init(data: Data(), kind: .frontCover, description: "album cover")
]
// write metadata changes
try audioFile.write()Warning
This library does not state or guarantee ABI stability despite packaging XCFramework's.
Whenever the version changes you should recompile.
This library is done using Swift C++ Interop (there are some limitations to consider).
Understanding Objective-C and Swift interoperability.
Currently supporting reading from most of the same types as SFBAudioEngine in C++ Bridge.
After cloning this repository you should call the following(in it's root directory), to fetch the git submodules:
git submodule update --initThe Package.swift in the root directory is a wrapper for underlying Package.swift in XCFrameworkPackage directory, you should work with/edit the latter.
To compile Package.swift in XCFrameworkPackage as bunch of .xcframework's, go into XCFrameworkPackage directory and call:
makeThis library would not be possible without any of this libraries:
