TransWikia.com

Call native code from Unity iOS build error

Game Development Asked by Atlantis on January 29, 2021

I created NativeCallProxy.cs in Unity

    public class NativeCallProxy: MonoBehaviour
    {
        [DllImport("__Internal")]
        public static extern void iOSUnloadUnityGame();

        public static void UnloadUnityGame()
        {
#if UNITY_IPHONE
            // Now we check that it's actually an iOS device/simulator, not the Unity Player. You only get plugins on the actual device or iOS Simulator.
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                iOSUnloadUnityGame();
            }
#endif
        }
    }

and created two files in Assets/Plugin/iOS
NativeCallProxy.m

#import <Foundation/Foundation.h>
#import "NativeCallProxy.h"

@implementation UnityBridgeAPI
id<UnityBridgeNativeCallsProtocol> api = NULL;
+ (void) registerAPIForNativeCalls:(id<UnityBridgeNativeCallsProtocol>)proxy {
    api = proxy;
}
@end

and NativeCallProxy.h

#ifndef NativeCallProxy_h
#define NativeCallProxy_h

@protocol UnityBridgeNativeCallsProtocol
@required
- (void)unloadUnityGame;
@end

__attribute__((visibility("default")))
@interface UnityBridgeAPI: NSObject
+ (void) registerAPIForNativeCalls:(id<UnityBridgeNativeCallsProtocol>)proxy;
@end


#endif /* NativeCallProxy_h */

and when I try to compile exported project I get an error in Xcode.

enter image description here

How can I figure out it?

One Answer

Just as the error says. You haven't defined "iOSUnloadUnityGame" that you have used in your NativeCallProxy class. You do have a method called "unloadUnityGame".

Answered by Daniel Ryan on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP