I haven't used either of these, but here's a couple of libraries that turned up in a search:
http://github.com/incanus/Simple-KML/
http://developmentseed.org/blog/2010/aug/12/kml-parsing-library-released-apples-ios-platform
Edit: it looks like both those libraries are parsers, not writers. You may have to create your own writer.
I'd say that using either of these libraries would save you a lot of time. That said, have a look at how KML is formed. It's just XML and making a track is really easy. Here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1" xmlns:trails="http://www.google.com/kml/trails/1.0">
<Document>
<name>RK_Running.kml</name>
<Placemark>
<name>Running 12/9</name>
<Style>
<LineStyle>
<color>ff0000ff</color>
<width>4</width>
</LineStyle>
</Style>
<MultiGeometry>
<LineString>
<tessellate>1</tessellate>
<coordinates>
138.968309,35.716577,17.0
138.967998,35.716859,17.0
138.967526,35.717252,20.0
138.967055,35.717494,20.0
</coordinates>
</LineString>
</MultiGeometry>
</Placemark>
</Document>
</kml>
Save this as a .kml and it will open in Google Earth