I am trying to allow users to upload a profile photo to Firebase Storage. The image gets uploaded during the sign up process of my app. The image is being uploaded to Fireba
You can't use a return statement for a function that contains a closure as the function will return before the closure has executed.
Instead change your function to use a completion handler such as
func uploadProfilePic(completion: @escaping (String?, Error?) -> ()) {
Then once you get your download url call the handler.
profilePhotosRef.downloadURL { (url, err) in
completion(url, err)
}
You can then use this function to populate your call to Cloud Firestore like so
self.uploadProfilePic() { (url, error) in
guard error....
if let url = url {
// do your upload here
}
}