I’m trying to add AudioKit (a Swift audio framework I’m involved with) to an OF project. I’m able to add the framework by changing the main.m
file to main.mm
, and the ofApp.cpp
file to ofApp.mm
(switching from C++ to Objective-C++ since I’m only working on a Mac).
I have a simple instrument defined in my Swift file (Oscillator.swift
). I’m able to access this file through the auto-generated header Xcode made for accessing Swift code, myProjectDebug-Swift.h
. If I import that file in main.mm
, I’m able to successfully create an instance of my oscillator, and hear it on startup. All groovy so far.
HOWEVER, if I do the same thing in ofApp.mm
, I get build errors as shown below (I’ve attached the relevant files to this post):
Does anyone have any idea why I would be able to access a Swift file in my main.mm file, but not the ofApp.mm file??
Below is the code in my main.mm
file that is working fine:
include “ofMain.h”
include “ofApp.h”
include “ofxGui.h”
include “myProjectDebug-Swift.h”
//========================================================================
int main( ){
OscillatorInstrument *instrument = [[OscillatorInstrument alloc] init];
}
And, this is the code in my ofApp.mm
file that does compile:
include “ofApp.h”
import “myProjectDebug-Swift.h”
void ofApp::setup(){
OscillatorInstrument *instrument = [[OscillatorInstrument alloc] init];
}
Below are the errors I get at the OscillatorInstrument ...
line:
Thank you!!!