Swift4 Version License Platform Readme Score

Provides a Swift version of the TCX XML format.


TcxDataProtocol is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'TcxDataProtocol'

Swift Package Manager:

dependencies: [
    .package(url: "", from: "0.2.0")

How to Use


let tcxUrl = URL(fileURLWithPath: "TestFile" + ".tcx")
let tcxData = try? Data(contentsOf: tcxUrl)

if let tcxData = tcxData {
    let tcxFile = try? TcxFile.decode(from: tcxData)


let build = Build(version: Version(major: 0, minor: 1, buildMajor: 0, buildMinor: 0), time: nil, builder: nil, type: .alpha)
let author = Author(name: "TcxDataProtocol", build: build, language: nil, partNumber: "11-22-33")

let lap = ActivityLap(startTime: Date(), totalTime: 45.0, distance: 12.0, maximumSpeed: nil, calories: 120, averageHeartRate: nil, maximumHeartRate: nil, intensity: .active, cadence: nil, triggerMethod: .manual, track: nil, notes: nil, extensions: nil)

let activity = Activity(sport: .biking, identification: Date(), lap: [lap], notes: nil, training: nil, creator: nil)

let activities = ActivityList(activities: [activity], multiSportSession: nil)

let database = TrainingCenterDatabase(activities: activities, courses: nil, author: author)

let TCXFile = TcxFile(database: database)

let encodedData = try? TCXFile.encode(prettyPrinted: true)

if let encodedData = encodedData {
    let xml = String(bytes: encodedData, encoding: .utf8)

Supported Elements

Supported Extensions


This package is developed and maintained by Kevin A. Hoogheem


BluetoothMessageProtocol is available under the MIT license