I'm trying to make sense of my iOS stack traces in...
# touchlab-tools
d
I'm trying to make sense of my iOS stack traces in my CMP project. I tried NSExceptionKt and that didn't work because it couldn't find
import NSExceptionKtBugsnag
. Then I tried Crashkios and I followed the tutorial to the end and it failed on
BugsnagConfigKt.startBugsnag(config: config)
because it didn't recognize
BugsnagConfigKt
. I feel like I'm taking crazy pills when they both won't work! Bugsnag works fine and its in the same spot, so I'm pretty confused 😖 I also used a basic CMP project to verify it wasn't anything weird with my config
f
KMP native crash logs make rarely sense; if you have at least all your stracktrace symbolicate, it’s a win.
Sometimes, the cause is at the bottom or even at the middle of the stack, especially when it’s happening inside a coroutine
FYI, Also, Sentry is also a correct alternative as it’s officially supported
r
It sounds like you are missing a small (but important) step in the dependency setup. For NSExceptionKt make sure to add the Swift part of the library to your Xcode project (see the Apple docs on how to add a SPM dependency). For CrashKiOS it sounds like the Kotlin dependency isn't exported to Swift. Are you using CocoaPods to integrate your shared module in the Xcode project? Or are you using the integrated Gradle command? If you are using the integrated Gradle command have a look at the Kotlin docs regarding exporting dependencies.
d
NSExceptionKt - Yeah I added the swift part of the lib to SPM, but still no dice 😞. I reverted for now, going to try out Sentry next. CrashKiOS - I am using Cocoapods to integrate. I followed the tutorial here, and my example app github is here. I did:
Copy code
commonMain.dependencies {
            ...
            api("co.touchlab.crashkios:bugsnag:0.8.6")
        }
gradle.properties:
Copy code
kotlin.native.cacheKind.iosX64=none
kotlin.native.cacheKind.iosSimulatorArm64=none
I tried doing this, but
sendHandledException
doesn't exist
Copy code
Bugsnag.sendHandledException(Exception("Some exception"))
Then in build.gradle.kts for my cocoapods I did
Copy code
cocoapods {
        summary = "My app"
        homepage = "Link to the Shared Module homepage"
        version = "1.0.0"
        ios.deploymentTarget = "16.0"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            isStatic = true
            export("co.touchlab.crashkios:bugsnag:0.8.6")
        }
    }
r
Alright, not sure what's going wrong with the NSExceptionKt dependency then. However the CrashKiOS sample isn't actually using Cocoapods to integrate the Kotlin framework. There is a build script that calls the Gradle command. Once you remove that script and update your podfile (like this ) it should work as expected.
d
Ahh yup your right, I am using a direct integration. Been a little bit since I set that up 😄 Removing the script and running a cocoapods integration works as expected, however, I need to do that to use build targets w/ buildKonfig to get build flavors basically, I also like that I don't have to rebuild the pod each time and can just run it from xcode. Given that is there a way to make CrashkiOS work with a direct integration? Any advice appreciated 🙏 ... also thats probably why NSExceptionKt wasn't working either
r
Yeah, just make sure to configure the dependency export as described in the Kotlin docs.
🙏 1
k
I just had an extended internal conversation about how linking and KMP/CMP needs a lot of improvement or CMP adoption is going to struggle (never mind just KMP adoption). CrashKiOS needs a pretty major refresh on that. Didn't read the whole thread, but from the replies, it looks like you're in good hands.