what languages in xcode can i bridge to unity for macOS?

24 Views Asked by At

I have had problem trying to make native popup for macOS recently in unity with the use of objective-c++ that looks like this

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>

@interface QuitFeatureMac : NSObject
+ (void)quitFeature:(NSString )title message:(NSString)message;
@end
@implementation QuitFeatureMac

+ (void)quitFeature:(NSString )title message:(NSString)message {
    NSAlert alert = [[NSAlert alloc] init];
    [alert setMessageText:title];
    [alert setInformativeText:message];
    [alert addButtonWithTitle:@"Yes"];
    [alert addButtonWithTitle:@"No"];

    NSInteger result = [alert runModal];
    if (result == NSAlertFirstButtonReturn) {
        NSLog(@"User clicked Yes");
    } else if (result == NSAlertSecondButtonReturn) {
        NSLog(@"User clicked No");
    }
}

@end
extern "C" {
    void _quitFeature(const chartitle, const char message) {
        NSStringfirstParameter = [NSString stringWithUTF8String:title];
        NSString *secondParameter = [NSString stringWithUTF8String:message];
        [QuitFeatureMac quitFeature:firstParameter message:secondParameter];
    }
}

now this works when running on unity, but when i run on xcode, either its error or it just doenst work at all

im not sure where im missing when it comes to running connecting the objective-c++ script to unity c# im not sure if it can be because of the game running on/with steam when trying to run on xcode, or if it has something to do with that

at this point i feel like im using the wrong bridging langauge, thats why im wondering, what langauges can be used or is mostly recommended when connecting scripts from xcode to unity scripts

i have tried manually adding the framework that the script is using,i have tried creating bundle or dylib for this script only, havent worked, i have made sure that in the c# script that i wanna call this objective-c++ script in has the exact name of the bundle, so like this

DllImport("bundlename")
DllImport("bundlename.bundle")
DllImport("bundlename.dylib")

i have amde sure that i have put the plugin in the plugins folder

0

There are 0 best solutions below