Swiftpack.co - RCCoop/RCGPX as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by RCCoop.
RCCoop/RCGPX 1.0.0
A library for reading/writing GPX files in Swift
⭐️ 1
🕓 4 weeks ago
iOS macOS watchOS
.package(url: "https://github.com/RCCoop/RCGPX.git", from: "1.0.0")



A simple library for reading & writing GPX tracks and waypoints in Swift, specifically designed for simplicity and ease of use.



Swift Package Manager:

.package(url: "https://github.com/RCCoop/RCGPX.git", .upToNextMajor(from: "1.0.0"))


The root of a GPX file is represented by the GPXDocument struct, which is used as a container for any number of waypoints and tracks.

When creating a GPXDocument from scratch (rather than reading from an existing file), you may optionally add a name for the person or program that created the file, as well as the arrays of tracks and waypoints.

public struct GPXDocument {
    public var creator: String?
    public var waypoints: [GPXWaypoint]
    public var tracks: [GPXTrack]

GPX Types

  • GPXTrack
    • .Segment
    • .Point
  • GPXWaypoint

Reading GPX Files

let fileUrl = ...
let fileData = try Data(contentsOf: fileUrl)
let gpxString = try? String(contentsOf: fileUrl, encoding: .utf8)

let documentFromData = try? GPXDocument(fileData)
let documentFromFileUrl = try? GPXDocument(fileUrl)
let documentFromString = try? GPXDocument(gpxString)

Writing GPX Files

let gpxDoc = GPXDocument(...)

let asData = gpxDoc.gpxData()
let asString = gpxDoc.gpxString()


  • AEXML for reading and writing XML files


Stars: 1
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.


Release Notes

Version 1.0.0
4 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics