Xcode Memory Graph shows leaks in brand new Kotlin Multiplatform + SwiftUI app (__NSArrayI, __NSCFString, MTLAttributeInternal)

2 weeks ago 18
ARTICLE AD BOX

I created a brand new Kotlin Multiplatform (Compose Multiplatform) app using the official template.

Without adding any custom code, Xcode’s Memory Graph reports leaks immediately on launch:

7 instances of __NSArrayI leaked

12 instances of __NSCFString leaked

30 instances of MTLAttributeInternal leaked

This happens even with the default SwiftUI + Compose setup.

SwiftUI entry point:

@main struct iOSApp: App { var body: some Scene { WindowGroup { ContentView() } } }

Compose hosted via UIViewControllerRepresentable:

struct ComposeView: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { MainViewControllerKt.MainViewController() } func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} } struct ContentView: View { var body: some View { ComposeView() .ignoresSafeArea() } }

KMP framework is built as static:

iosTarget.binaries.framework { baseName = "ComposeApp" isStatic = true }

The memory usage stabilizes over time and does not grow, but Xcode still flags these objects as leaks.

Is this a known false positive related to SwiftUI / Metal / Kotlin Multiplatform, or is there something incorrect in this setup?

Read Entire Article