Nico Gutraich Nico Gutraich - 1 year ago 126
Swift Question

How to make iPhone vibrate using Swift?

I need to make the iPhone vibrate, but I don't know how to do that in Swift. I know that in Objective-C, you just write:

import AudioToolbox

But that is not working for me.

Answer Source

Short example:

import UIKit
import AudioToolbox

class ViewController: UIViewController {

    override func viewDidLoad() {



load onto your phone and it will vibrate. You can put it in a function or IBAction as you wish.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download