Recording from the microphone is a tricky task – with a fair bit of setup. However it’s all laid out here in plain language 🙂

1. The very first step is to request permission to use the microphone:

In your Info.plist set the following property:

Privacy – Microphone Usage Description, Set the string to whatever you want to say to your user. Here’s a screenshot:
Screen Shot 2016-08-06 at 19.38.38

2. Request permission, this should be fired from within the current View Controller:

If the above doesn’t show anything MAKE SURE you’ve done step 1. No description in the Info.plist means it won’t ask for permission!

Note that if the user denies access then you cannot fire off another permission request. The USER has to go into settings and manually change permission (you should perhaps tell them this).

3. Now it’s time to setup recording. I’m doing this from within a View Controller (most common case) but you can adapt instructions according to your needs.

Inherit from AVAudioRecorderDelegate

Create a class level variable to hold the recorder. Be careful not to create this inside a function as you may encounter scope problems)

4. Create a URL path where you’ll store the recording. This is usually the documents folder of your app.

5. And now for the recording!

6. Optional but do it if you’re a good programmer. Set up the delegate function that fires when recording ends:

I use the above step to update my UI and tell the user if anything is messed up!

That’s all folks!

Where to go Next

This tutorial comes straight out of The Complete iOS Developer Course. Over 40 hours long it contains everything you need to create awe inspiring apps fast!

Click here to check it out!

How to Record Sound with Swift 3 and iOS 10

Leave a Reply

Your email address will not be published. Required fields are marked *

Share This

Want this Post in Easy to Understand Video Form?

Then get the Complete iOS Developer Course. Over 50 hours of pure Swift coding goodness designed to turn you into a coding master!

One Time Offer - $9! Click to Get it!

WARNING: Once this box is closed the offer will not be shown again.

Thank you!