Swift Facebook Image Picker

On a monday morning, your boss let you a note : “Hey, what if you add an easy way for the user to chose his profile picture from his Facebook account ? Could probably do it with the Facebook SDK in less than a couple of hours.”

Fine ! Let’s take a look to the amazing Facebook’s documentation, they probably made a native image picker which permit to log the user, retrieve user’s albums and display pictures of each albums.

Your face when you realize there is nothing in the native Facebook SDK

It turned out there is no easy and simple way to do elegant Facebook image pickers with the native iOS Facebook SDK.

You will need to handle Facebook login, denied photos permission, parse user’s albums from the Graph API, load albums cover, parse album’s pictures, load and cache pictures. What a really painful task !

And all this, like said your boss, in less than 1 or 2 hours.

There is a solution ! 🎉

There are a couple of websites and old libraries which allow it to be done. Only this is always in an old Swift version or with an old Facebook SDK. That is why I decided to make “GBHFacebookImagePicker”, my own Swift Facebook picker and release it to the OpenSource community under the MIT licence.

Main features

The picker provide a really simple way to ask users for Facebook’s photos permission and display all the Facebook’s account albums. When albums pictures are displayed the user can easily choose one of them, then the picker download the chosen picture in the highest quality.


Sometimes users can be strange (or having crazy behaviors) and denied the photo permission. In that case, the picker detect it and ask again for permission.

The picker provide also a simple way for translate the popup.


GBHFacebookImagePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "GBHFacebookImagePicker"

Usage 🗝

import GBHFacebookImagePicker
  • Implement the GBHFacebookImagePickerDelegate protocol:
// MARK: - GBHFacebookImagePicker Protocolfunc facebookImagePicker(imagePicker: UIViewController, didSelectImage image: UIImage?, WithUrl url: String) {
// Do whatever you whant with the picked image or url ...
func facebookImagePicker(imagePicker: UIViewController, didFailWithError error: Error?) {
func facebookImagePicker(didCancelled imagePicker: UIViewController) {
print("Cancelled Facebook Album picker")
  • Display the picker :
let picker = GBHFacebookImagePicker() 
picker.presentFacebookAlbumImagePicker(from: self, delegate: self)


Some applications already use this picker like :

What about yours ? If your application also use this picker, feel free to contact me or post a comment with its name 😁

What’s next ? 🚀

Customization will be the next focus. With font, color or border customization.

Some people have asked me to make multiple selection features, which probably be one of the next features too.

Feel free to contribute and make pull request on Github.

If you ❤️️ it, feel free to click on the green heart bellow 👇🏽, or simply star it ★ on Github ❤️️

If you don’t ❤️️ it say to me why, I will be happy to discuss about it 😁

Florian G.contact@floriangabach.fr

Startup, software development, sport…

Startup, software development, sport…