How to Build A Simple iOS 10 Flashlight App For iPhone

Today, we’re going to build a simple iOS 10 best Flashlight app for iPhone. This iOS app tutorial contains absolutely no complex design. However, if you wish to add some interactive animations or something, you can design the flashlight mobile app with a graphic design software such as Photoshop. 

Let’s Get Started

Create a new project under file menu and select “Single View Application.”


In the next tab, modify your project details and click on submit.


Now, add a button in your Main.Storyboard ViewController

Set a click event “actionTorchClick”

Next, import AVFoundation in ViewController.swift

Declare a boolean variable ‘is Torch’ to turn ON/OFF the torch.

Var isTorch = false

Now integrate the code snippet to touch ON/OFF in “actionTorchClick” method.

@IBAction func actionTorchClick(sender: AnyObject) {


        guard let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) else { return }


        if device.hasTorch {

            isTourch = !isTourch

            do {

                try device.lockForConfiguration()


                if isTourch == true {

                    device.torchMode = .On

                } else {

                    device.torchMode = .Off




            } catch {

                print("Torch is not working.")


        } else {

            print("Torch not compatible with device.")



And Done!

Simple right? However, it’s also possible to adjust the flashlight’s brightness with couple of tweaks in the source code. And if you don’t know where the flashlight feature can be used, well the answer is, Photo editing apps.

Yes, if you might have already noticed that all of them provide an in-app camera with all features including flashlight control. So while developing a photo editing application or flashlight in iPhone, it’s possible to include flashlight feature so that users can capture better quality pictures. And if you need to create an iOS app from scratch, write down your app requirements, hire swift developer, and execute your startup plan.

Grab a free copy of iPhone Flashlight app demo from Github.

Author Bio
Hitesh Trivedi
Hitesh Trivedi
Designation: iOS Team Lead

Hitesh Trivedi is an iOS Team Lead at Space-O Technologies. He has over 10 years of experience in iOS app development. He has guided to develop over 100 iPhone apps with unique features and functionalities. He has special expertise in Swift and Objective-C.