Stacy Y
07/18/2024, 3:57 AM#import <Foundation/Foundation.h>
@interface SimpleBridge : NSObject
+ (NSString *)sayHello;
@end
SimpleBridge.m
#import "SimpleBridge.h"
@implementation SimpleBridge
+ (NSString *)sayHello {
return @"Hello from Objective-C";
}
@end
simpleBridge.def
headers = SimpleBridge.h
headerFilter = SimpleBridge.h
compilerOpts = -I${projectDir}/src/iosMain/headers
gradle:
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 FAILEDException 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)