Hello, I have an ios oc header file to cinterop in...
# multiplatform
x
Hello, I have an ios oc header file to cinterop in kmm:
Copy code
#ifndef socket_swift_bridge_h
#define socket_swift_bridge_h

// <https://github.com/socketio/socket.io-client-swift>
@import SocketIO;

#endif /* socket_swift_bridge_h */
then get error:
Copy code
Exception in thread "main" java.lang.Error: /xxx/socket_swift_bridge.h:14:1: error: use of '@import' when modules are disabled
	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1003)
	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:992)
	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
so, how to solve it? thx
v
Hi, Unfortunately module import is not supported by cinterop tool. So
@import SocketIO
should be replaced with something umbrella header import, something like
#import <SocketIO/SocketIO.h>
x
Thanks for your reply! https://github.com/socketio/socket.io-client-swift Could u tell me what's the umbrella header file? I try
#import <Socket.io-client-swift-umbrella.h>
Copy code
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif


FOUNDATION_EXPORT double SocketIOVersionNumber;
FOUNDATION_EXPORT const unsigned char SocketIOVersionString[];
, then get another error:
Copy code
error: use of undeclared identifier 'SocketIOStatusNotConnected'
SocketIOStatusNotConnected
v
Not sure but probably
#import <SocketIO/SocketIO-Swift.h>
will work, give it a try
x
fatal error: 'SocketIO/SocketIO-Swift.h' file not found
All of above do NOT work.🤔
Copy code
//#import <SocketIO/SocketIO-Swift.h>
//#import <Socket.io-client-swift/Socket.io-client-swift-Swift.h>
//#import <SocketIOClientSwift/SocketIOClientSwift-Swift.h>
//#import <Socket.io-client-swift/SocketIOClientSwift-Swift.h>