EntryPointNotFoundException: почему метод не обнаруживается для устройства IOS?

Приведенный ниже код представляет собой полный код плагина. Я пытаюсь получить широту и долготу с помощью этого плагина. Я создал сценарий на C#, вставил этот код и переименовал его в файл Position.mm. Я добавил один SDK, в котором находится папка плагина. Так что изначально Я скопировал в эту папку. Показывалось сообщение об ошибке EntryPointNotFoundException: _GetCoordinates Getposition.GetCoordinates (). Я создал папку Assets/Plugins и скопировал в нее не работающий плагин.

#import "Position.h"
#import <CoreLocation/CoreLocation.h>
#import <CoreMotion/CoreMotion.h>

//Convert a C++ string to NSString
NSString* CPPStringToIOSString(const char* cppString)
{
    return cppString?[NSString stringWithUTF8String: cppString] : nullptr;
}

//Convert an NSString to C++ string.
const char* IOSStringToCPPString(NSString * iosString)
{
    if ([iosString length])
    {
        const char* str = [iosString UTF8String];
        if (str && strlen(str))
        {
            char* unityString = static_cast<char*>(malloc(strlen(str) + 1));
strcpy(unityString, str);
            return unityString;
        }
    }

    return nullptr;
}


static LocationServiceInfo GetLocationServiceInfo()
{
    static LocationServiceInfo info;
    return info;
}

//Exports:
extern "C" {

    //When called, returns a CLLocationCoordinate2D to Unity.
  CLLocationCoordinate2D _GetCoordinates()
{
    CLLocationManager* manager = GetLocationServiceInfo().GetLocationManager();
    return [manager getCurrentLocation];
}

//When called, registers a listen with LocationManager.
//The listener is called whenever the location has updated/changed.
void _RegisterLocationUpdateHandler(void(* callback)(double, double))
{
    //Implement your own logic for this..
    //Then call `callback` with the lat and lon.
    GetLocationServiceInfo().onLocationDidUpdate = ^ (double lat, double lon) {
        if (callback)
        {
            callback(lat, lon);
        }
    };
}
}

Любая проблема с этим плагином или то, как я к нему обращаюсь. Ниже приведен способ, которым я пытаюсь получить доступ к значениям из плагина.

//Struct representing coordinates received from the iOS plugin.
public struct CLLocationCoordinate2D
{
    double latitude;
    double longitude;
}

//Imported function.
[DllImport("__Internal")]
private static extern CLLocationCoordinate2D _GetCoordinates();

//Call the imported `GetCoordinates` when this function is called.
public static CLLocationCoordinate2D GetCoordinates()
{
    return _GetCoordinates();
}

В методе обновления

void Update () 
{
    if (GetCoordinates().ToString() != null)
    {
        Debug.Log("Getcordinates Plugin " + GetCoordinates().ToString() );
    }
}

0 ответов

Другие вопросы по тегам