How to consume swift class from objective-c++ in ios-project?
Apple docs talk only about objective c : https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
I tried doing this -
Console.swift
public class Console : NSObject {
public func Dump() -> Void {
let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Console")
os_log("url = %@", log: log, "Some thing here")
}
}
ConsoleDelegate.hpp
#ifndef ConsoleWrapper_h
#define ConsoleWrapper_h
#import <Foundation/Foundation.h>
#import <Interop-Swift.h>
@interface ConsoleDelegate : NSObject {
@private
Console* console;
}
- (ConsoleDelegate*) init;
- (void) DumpWrapper;
@end
#endif /* ConsoleWrapper_h */
ConsoleDelegate.mm
#import "ConsoleDelegate.hpp"
#import <Foundation/Foundation.h>
@implementation ConsoleDelegate
- (ConsoleDelegate*) init {
console = [[Console alloc] init];
return self;
}
- (void) DumpWrapper {
[console Dump];
}
@end
But i get errors like -
/path/to/file/Interop-Swift.h:192:39: No type or protocol named 'UIApplicationDelegate'
If i rename ConsoleDelegate.mm -> ConsoleDelegate.m then it compiles without any errors.