Just to reply to myself here, but for anyone that wants to get JUCE in iOS I figured some steps to make it possible. Essentially you need to compile your App Source alongside the JUCE modules with the Unity Wrapper… It’s a bit of a jump around, but here are some basic steps outlining what I did. I’ve tested using the GainPlugin example and all seems to be working well I’m happy to say
- Create your plugin with a name like “audioplugin_MyPlugin”.
- Create a MacOSx exporter of your plugin.
- Within XCode duplicate the static library (.a file) and rename it so it includes iOS at the end, or anything to differentiate it from the other library.
- Select the library and then go to Build Phases and add the “include_juce_audio_plugin_client_Unity.cpp” to your compile sources.
- Then build the static library. Make sure you select the correct build configuration so you build the iOS one and not the MacOSx one.
- Drag and drop your static library plugin into your Unity projects “Plugins/iOS” folder
- Click on the plugin and within the inspector select the following frameworks which JUCE depends on: Accelerate, CoreImage and MobileCoreServices
- Create a file “MyPluginAppController.mm” within the “Plugins/iOS” folder
- Within “MyPluginAppController.mm” we need to override the UnityAppController.mm preStartUnity function to include the Audio Plugin registration. To do this we add the following code:
#import "UnityAppController.h"
@interface MyPluginAppController : UnityAppController {}
@end
extern "C" {
// We have to manually register the Unity Audio Effect plugin.
struct UnityAudioEffectDefinition;
typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)(
struct UnityAudioEffectDefinition*** descptr);
extern void UnityRegisterAudioPlugin(
UnityPluginGetAudioEffectDefinitionsFunc getAudioEffectDefinitions);
extern int UnityGetAudioEffectDefinitions(UnityAudioEffectDefinition*** definitionptr);
} // extern "C"
@implementation MyPluginAppController
- (void)preStartUnity {
[super preStartUnity];
UnityRegisterAudioPlugin(&UnityGetAudioEffectDefinitions); // intialize native audio plugins
}
@end
IMPL_APP_CONTROLLER_SUBCLASS( MyPluginAppController )
- Then set your player build settings to be iOS and generate the Unity iOS XCode project by clicking “Build”
- Select your .app target and set your app signing credentials.
- Build your unity app for iOS
It’s quite a number of extra steps and I think key is the fact there is some extra work to be done to load the plugin correctly into the iOS project genrated by Unity (the preStartUnity stuff)… I think some thought needs to be given when you want to load multiple plugins. That will be my next task.
Also, in order to control the parameters from Unity, you’ll need to create a regular MacOSx plugin .bundle. Within it is the C# control script that you can use to expose parameters in the plugin to be controlled from script.
Hope it helps some of you!