In this project we are choosing a photo from the photo library, editing it, and then saving it in a file that our app can access later.
Since we are just pulling the image from the photo library, we don't really have any name to reference it by. So, we are just creating a random ID number for it, and using that for a name.
Using a UUID just makes it easy for us to create individual names for each photo, and ensure that they will all be unique, without having to create them ourselves.
The line of code you mentioned...
let imagePath = getDocumentsDirectory().appendingPathComponent(imageName)
is basically just finding the Documents directory for us, and creating a file in it with the file name matching the random ID number that we generated to use as the name for that photo.
Then we write the jpeg image data to the file that was created.