Swift Package Index


Simple audio playback in Swift


  • The latest stable release is 2.0.0. Released about 1 year ago.
  • The last commit to develop was about 1 year ago.

Swift Version Compatibility

  • 2.0.0 and develop
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 2.0.0 and develop
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

SwimpleAudio

version issues license size

Simple audio playback in Swift.

SwimpleAudio is part of the Swimple packages series. Swimple stands for Simple Swift. These packages make coding with Swift simpler and more convenient.

Swift Package Manager 📦

From within Xcode 11 or up you can add SwimpleAudio as a Swift Package:

  1. Select your project
  2. Go to Swift packages
  3. Add a package (+)
  4. Enter https://github.com/lloydkeijzer/SwimpleAudio.git as the package repository url
  5. Select the version you want to use and click next

You're now able to import SwimpleAudio in your source code 🎉

Binding audio 🔊

You can easily bind any sound effect to an action of a UIControl object.

class ViewController: UIViewController {

  let button = UIButton()

  override func viewDidLoad() {
    super.viewDidLoad()
    button.addSound(named: "button_click.mp3", for: .touchUpInside)
  }
  
  deinit {
    button.removeTargets()
  }
}

Delaying a sound effect after an UIControl.Event triggers.

button.addSound(named: "button_click.mp3", for: .touchUpInside, delay: .seconds(3))

Repeating a sound effect a number of times after an UIControl.Event triggers.

button.addSound(named: "button_click.mp3", for: .touchUpInside, repeats: 5)