Latest 1.1.0
Homepage https://github.com/fousa/gpxkit
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0, requires ARC
Dependencies AEXML
Authors

GPXKit CI Status Version License Platform

GPXKit is allows you to easily parse a GPX file in Swift.

GPX format

The currently supported GPX format is version 1.1 as described in the schema documentation.

Integration

Add this pod to your Podfile by adding the following line:

pod 'GPXKit', '~> 1.1'

It’s important to add the version to the pod 'GPXKit', this way you are sure that a next update of the pod will not break your code.

Usage

You can take a look at the different specs on how to use this pod. But for now I describe in short how it can be used.

Here is a sample GPX file with some data:

<gpx creator='GPXKit'>
  <metadata>
    <name>Jelle Vandebeeck</name>
    <desc>A GPX file</desc>
    <time>2016-03-10T10:05:12+02:00</time>
    <keywords>hiking, forest, wild</keywords>
  </metadata>
</gpx>                    

The only thing you have to do is make sure to get the contents of the GPX file into an NSData structure. When you have this you can easily parse the file into a GKFile.

let content: String = '...'
let data = content.dataUsingEncoding(NSUTF8StringEncoding)
let file = try! GKParser(data: data).parse()

When the parsing fails an error will be thrown. There are currently two types of errors:

  • invalidData thrown when the data object is empty.
  • invalidFormat thrown when the data object can’t be parsed.
  • invalidVersion thrown when the data object contains an incorrect version of the GPX file.

License

GPXKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "GPXKit",
    "version": "1.1.0",
    "summary": "Parse a GPX file into a readable format with Swift.",
    "description": "This pod makes it possible to parse a GPX file to a format that cannbe easily used in your code.",
    "homepage": "https://github.com/fousa/gpxkit",
    "license": "MIT",
    "authors": {
        "Jelle Vandebeeck": "jelle@fousa.be"
    },
    "source": {
        "git": "https://github.com/fousa/gpxkit.git",
        "tag": "1.1.0"
    },
    "social_media_url": "https://twitter.com/fousa",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "requires_arc": true,
    "source_files": "Sources/**/*",
    "dependencies": {
        "AEXML": [
            "~> 3.0"
        ]
    }
}

Pin It on Pinterest

Share This