Swiftpack.co - Package - phillfarrugia/PhotoLibraryPicker


A basic wrapper around UIImagePickerController that simplifies presenting the Photo Library / Camera picker.

Getting Started

Installation with CocoaPods

pod 'PhotoLibraryPicker'

Installation with Carthage

github "phillfarrugia/PhotoLibraryPicker"


class ViewController: UIViewController {

    // Instantiate a PhotoLibraryPicker
    let imagePickerHandler = PhotoLibraryPicker()

    override func viewDidLoad() {

	// Present Photo Library Picker
        imagePickerHandler.presentLibraryPicker(fromViewController: self) { (result) in
            switch result {
            case let .completed(asset):
            case .cancelled:


Photo Library

Present a Photo Library picker (allows users to select either a photo, or a video from their Camera Roll or Albums) by calling presentLibraryPicker(fromViewController:completion:) and pass the View Controller to present from as well as a completion handler to be called once the user has picked an asset.


Present a Camera picker (allows users to take a photo or a video from their camera) by calling presentCameraPicker(fromViewController:completion:) and pass the View Controller to present from as well as a completion handler to be called once the user has captured a photo or video.

Handling Results

Results of both the Photo Library and Camera picker are encapsulated in a PhotoLibraryPickerResult enumuration (see The Power of Result Types in Swift), that is either cancelled - meaning user has cancelled and opted not to select a photo or video; or completed - the user has selected an asset which is passed as an associate value.


Photos or Videos selected by the user are represented as a PhotoLibraryAsset struct containing the assetType (image, or video) and source (library, or camera).


PhotoLibraryPicker was created by Phill Farrugia.

It was originally created for use in a private project, and was open sourced to encourage decoupling and reusability as well as for the sake of trending towards open source software and building modular reusable frameworks.


PhotoLibraryPicker is available under the MIT license. See the LICENSE file for more info.


Stars: 2
Help us keep the lights on


Used By