When it comes to building an app to take pictures and capture videos in iOS, Apple provides two different approaches: UIImagePickerController

and AVCaptureSession.

UIImagePickerController is the easier way to get up and running, since you can have a working solution with a few lines of code. However, this simplicity comes at a cost, as it makes it harder to customize UI and to add custom functionalities to the camera (e.g. tap to focus).

On the other hand, AVCaptureSession , which is part of the AVFoundation framework, enables more customization flexibility, while making it harder to configure and manage. Its complexity and known headaches associated with its usage can drive some developers away.

Camera Manager was created to make it easy to interact with AVCaptureSession and, since its creation, aims to provide the flexibility of AVFoundation , while hiding all the nitty-gritty details from the developer. This allows the developer to focus on making a beautiful custom UI and achieve awesome things with photos without the need to reinvent the wheel.

Camera Manager provides a simple custom iOS camera view to easily capture photos and record videos with:

front/rear camera selection;

cameraManager.cameraDevice = .Front || .Back

tap to focus;

cameraManager.shouldEnableTapToFocus = true || false

pinch to zoom;

cameraManager.shouldEnablePinchToZoom = true || false

exposure slider;

cameraManager.shouldEnableExposure = true || false

flash mode;

cameraManager.flashMode = .Off || .On || .Auto

camera quality output;

cameraManager.cameraOutputMode = .StillImage || .VideoWithMic || .VideoOnly

cameraManager.cameraOutputQuality = .Low || .Medium || .High

focus mode;

cameraManager.focusMode = .autoFocus || .continuousAutoFocus || .locked

exposure mode;

cameraManager.exposureMode = .autoExpose || .continuousAutoExposure || .locked || .custom

flip front camera image;

cameraManager.shouldFlipFrontCameraImage = true || false

custom album names for image and video;

cameraManager.imageAlbumName = "Image Album Name" cameraManager.videoAlbumName = "Video Album Name"

EXIF metadata;

save location to EXIF.

cameraManager.shouldUseLocationServices = true || false

To provide all these capabilities, Camera Manager uses AVCaptureSession , which according to Apple is: "an object that manages capture activity and coordinates the flow of data from input devices to capture."

Instead of manually creating a capture session, obtaining and configuring the necessary capture devices, creating inputs using the capture devices, and configuring a video/photo output object to process captured videos/images, the developer only needs to add the preview layer to the desired view.

let cameraManager = CameraManager() cameraManager.addPreviewLayerToView(self.cameraView)

All the changes to the AVCaptureDevice , such as setting the flash mode and switching between the front and back cameras, are safely done and configured by Camera Manager.

And then when capturing an image:

cameraManager.capturePictureWithCompletion({ (image, error) -> Void in // handle image })

Also, to start and stop the recording of a video:

cameraManager.startRecordingVideo() cameraManager.stopVideoRecording({ (videoURL, error) -> Void in NSFileManager.defaultManager().copyItemAtURL(videoURL, toURL: self.myVideoURL, error: &error) })

As demonstrated, Camera Manager provides the flexibility from AVCaptureSession while maintaining the simplicity from UIImagePickerViewController.

There are some alternatives available, but Camera Manager has a few strong points that make it an exceptional choice:

It is written in Swift: many of the most used alternatives are written in Objective-C. Given that almost every new app is written in Swift and Apple commits to the language, it makes sense to use Swift to ensure that the app will be way more future-proof.

It is highly configurable: Camera Manager gives the developer full control of the functionality needed to build great camera apps.

Focus on functionality, not UI: some libraries come bundled with their own UI, while Camera Manager focuses on the functionality and gives the developer full control to implement the UI as pleased.

We encourage you to try it. Camera Manager has an example app that you can run on your device. You'll need a real device to run it, due to the use of AVFoundation camera API's which are unavailable on the iOS simulator.

Found this article useful? You might like these ones too!