After much searching I found and adapted this
This turns cclocation data into a suitable NSDictionary
#import <ImageIO/ImageIO.h>
+(NSMutableDictionary *)updateExif:(CLLocation *)currentLocation{
NSMutableDictionary* locDict = [[NSMutableDictionary alloc] init];
CLLocationDegrees exifLatitude = currentLocation.coordinate.latitude;
CLLocationDegrees exifLongitude = currentLocation.coordinate.longitude;
[locDict setObject:currentLocation.timestamp forKey:(NSString*)kCGImagePropertyGPSTimeStamp];
if (exifLatitude <0.0){
exifLatitude = exifLatitude*(-1);
[locDict setObject:@"S" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
}else{
[locDict setObject:@"N" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
}
[locDict setObject:[NSNumber numberWithFloat:exifLatitude] forKey:(NSString*)kCGImagePropertyGPSLatitude];
if (exifLongitude <0.0){
exifLongitude=exifLongitude*(-1);
[locDict setObject:@"W" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
}else{
[locDict setObject:@"E" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
}
[locDict setObject:[NSNumber numberWithFloat:exifLongitude] forKey:(NSString*) kCGImagePropertyGPSLongitude];
return [locDict autorelease];
}
Then I add it to the existing metadata that you get through the camera (which doesn't by default have the gps data)
I get the original metadata like this
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[imageMetaData setDictionary:[[info objectForKey:UIImagePickerControllerMediaMetadata] copy]];
}
then I add the gps dictionary the previous method produces.
[imageMetaData setObject:currentLocation forKey:(NSString*)kCGImagePropertyGPSDictionary];
[library writeImageToSavedPhotosAlbum:[viewImage CGImage] metadata:imageMetaData completionBlock:photoCompblock];