Hi folks, We are looking to integrate our SDK pro...
# multiplatform
s
Hi folks, We are looking to integrate our SDK product into a compose multiplatform app. This will require a bridge from kotlin to objc-c and/or swift to access APIs of the native SDK. Trying to get a simple example of a function call from Kotlin to obj-c but hitting an odd exception at compile time. (I'm also assuming that I need to call through obj-c in order to get to swift? i.e. can't call directly?) Any ideas? SimpleBridge.h
Copy code
#import <Foundation/Foundation.h>

@interface SimpleBridge : NSObject

+ (NSString *)sayHello;

@end
SimpleBridge.m
Copy code
#import "SimpleBridge.h"

@implementation SimpleBridge

+ (NSString *)sayHello {
    return @"Hello from Objective-C";
}

@end
simpleBridge.def
Copy code
headers = SimpleBridge.h
headerFilter = SimpleBridge.h

compilerOpts = -I${projectDir}/src/iosMain/headers
gradle:
Copy code
applyDefaultHierarchyTemplate()

iosX64()
iosArm64()

listOf(
    iosX64(),
    iosArm64()
).forEach {
    it.binaries.framework {
        baseName = "ComposeApp"
        freeCompilerArgs += listOf(
            "-Xbinary=bundleId=io.myapp.example",
            "-Xbinary=bundleShortVersionString=1.0",
            "-Xbinary=bundleVersion=1"
        )
        isStatic = true
    }
    it.compilations {
        val main by getting {
            cinterops.create("simpleBridge") {
                defFile("src/iosMain/nativeInterop/simpleBridge.def")
                packageName("io.myapp.example")
                includeDirs("src/iosMain/headers")
            }
        }
    }
}
> Task :composeApp:cinteropSimpleBridgeIosArm64 FAILED
Exception in thread "main" java.lang.Error: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h6011: error: expected identifier or '(' at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:275) at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1256) at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1239) at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1235) at org.jetbrains.kotlin.native.interop.gen.jvm.DefaultPlugin.buildNativeIndex(Plugins.kt:33) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:315) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLibSafe(main.kt:247) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.access$processCLibSafe(main.kt:1) at org.jetbrains.kotlin.native.interop.gen.jvm.Interop.interop(main.kt:105) at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:49) at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:23) at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:44)
Task composeAppcinteropSimpleBridgeIosX64 FAILED
Exception in thread "main" java.lang.Error: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h6011: error: expected identifier or '(' at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:275) at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1256) at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1239) at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1235) at org.jetbrains.kotlin.native.interop.gen.jvm.DefaultPlugin.buildNativeIndex(Plugins.kt:33) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:315) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLibSafe(main.kt:247) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.access$processCLibSafe(main.kt:1) at org.jetbrains.kotlin.native.interop.gen.jvm.Interop.interop(main.kt:105) at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:49) at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:23) at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:44)
🧵 6