I made some custom plugins by using native audio sdk. The imported bundle works well on Mac, but when I build the game on iOS the audio processing simply does not work.
I tried to follow some of the advice that I found in this thread:
But then I get an error when I build the XCode project for iOS. In particular, after registering the plugin in preStartUnity{}, in UnityAppController.mm, I get this errors:
“Using of undeclared identifier ‘MetalUpdateDisplaySync’” in file MetalHelper.mm, line 94
“‘MTLResourceStorageModeManaged’ is unavailable: not available on iOS” in file MetalHelper.mm, line 116
“‘MTLResourceStorageModeManaged’ is unavailable: not available on iOS” in file MetalHelper.mm, line 164
Is anyone aware of any documentation that shows the steps for correctly importing a bundle and a static library on Unity for iOS?
Thanks!
Same error for the exact same reason.The errors relate to Metal and OSX flags, I am curious why they appear on an iOS build. Taking away the OSx dependencies from AudioPluginInterface.h does not give the errors above, but throws
Undefined symbols for architecture arm64:
"_UnityGetAudioEffectDefinitions", referenced from:
-[UnityAppController preStartUnity:] in UnityAppController.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Yeah, also getting the same errors when trying to build native audio plugin for iOS.
Which version of Unity are you both running?
The only way I could remove the error was by changing line 13 “AudioPluginInterface.h” to 0.
# define PLATFORM_OSX 0
This allowed my project to build. But when trying to deploy, the app crashes. Need to do further investigation to see if it’s the plugin causing the crash, but I suspect it is.
Edit: I was being stupid. I think this flag definitely needs to be set! haha
Just for those who may run into the same issue. I managed to solve it by omitting the import for “AudioPluginInterface.h” and rather defined the functions explicitly in UnityAppController.mm as follows.
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"
- (void)shouldAttachRenderDelegate {}
- (void)preStartUnity {
UnityRegisterAudioPlugin(UnityGetAudioEffectDefinitions);
}
I did run into the issue of certain plugins that required MIDI not compiling. I just needed to include the according frameworks in the iOS project
For this “_UnityGetAudioEffectDefinitions” reference error, the root cause is that you did not compile the AudioNativePlugin source code into .a file correctly. Please check the Xcode proj → Build Phases → Compile Sources