swiftxcodeaudiokit

AudioKit - Cannot find 'Oscillator' in scope


I have an iOS project in Xcode (SwiftUI interface and Swift language), for which I want to use the AudioKit Oscillator function. I have added the package dependencies for AudioKit 5.6.1 but I always get an error message behind the line let oscillator = Oscillator(waveform: Table(.sine)) in my ContentView.swift that says Cannot find 'Oscillator' in scope and the project build fails.

Screenshot of my example code line that includes the 'Oscillator' function

Not sure if it's relevant but I am using Xcode 15.0 on an Intel Macbook Pro with MacOS Ventura (13.6).

I have tried different Xcode versions (15.0 / 14.3.1), as well as different AudioKit versions (5.6.1 / 5.3.3 / 5.0). The AudioKit packages, I have installed via Cocoapods as well as with the package manager in xcode, every time with the same result.

I saw that someone else had a similar issue, not finding another function in AudioKit 5 and they used import CAudioKit instead of import AudioKit. However, when I try this, I get another error that says No such module 'CAudioKit'

I have spent multiple hours already trying to resolve this and to find reports about similar issues but I think it's time for my first post here. It would be great if anyone could help. Thank you!


Solution

  • The oscillator you are searching for is a class in AudioKit's extension framework SoundpipeAudioKit.

    You will need to add that package dependency to your project and then add import SoundpipeAudioKit in the ContentView file.