Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Audio Native audio plugin bundle does not work on iOS

Discussion in 'Audio & Video' started by Rickr922, Dec 4, 2019.

  1. Rickr922

    Rickr922

    Joined:
    Oct 16, 2019
    Posts:
    1
    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:

    https://forum.unity.com/threads/native-audio-plugin-bundle-import-settings-for-ios-build.315590/

    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!
     
  2. cerkut

    cerkut

    Joined:
    Mar 6, 2017
    Posts:
    6
    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)


    The closest pointer I've found is this: https://github.com/playdots/UnityPd#ios Now I am investigating their AudioPluginInterface.h (written for Unity 5.x it seems).
     
  3. toneTechnican

    toneTechnican

    Joined:
    Oct 22, 2019
    Posts:
    5
    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.

    Code (CSharp):
    1. #   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
     
    Last edited: Aug 30, 2020
  4. toneTechnican

    toneTechnican

    Joined:
    Oct 22, 2019
    Posts:
    5
    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 :)
     
    Last edited: Sep 18, 2020
    CharlesVerron likes this.
  5. yutingchen_unity

    yutingchen_unity

    Unity Technologies

    Joined:
    Jul 5, 2019
    Posts:
    5
    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