A problem occurred configuring project ':kmp'. > Sentry Cocoa Framework not found at /user/path/.../
Platform
Apple
Installed
None
Version
0.1.0
Steps to Reproduce
- Create a new KMP app project and use "Regular Framework" for distribution to Xcode.
- Add the Sentry KMP plugin.
- Sync gradle and the error will appear. The same one mentioned in this issue -> https://github.com/getsentry/sentry-kotlin-multiplatform/issues/303
Expected Result
Sentry is added to my KMP project and let me build it.
Actual Result
Cannot sync gradle, the following error appears: A problem occurred configuring project ':shared'.
Sentry Cocoa Framework not found at /path/to/iosApp/build/SourcePackages/artifacts/sentry-cocoa/Sentry-Dynamic/Sentry-Dynamic.xcframework/ios-arm64 or /path/to/iosApp/build/SourcePackages/artifacts/sentry-cocoa/Sentry/Sentry.xcframework/ios-arm64
hey, this is definitely a docs issue and an error message issue, you have to add the Sentry-Cocoa dependency via SPM first if you use a regular framework. we should mention it in the error message as well
I added Sentry SPM dependency to the iosApp and the problem persists. I also tried with Sentry-Dynamic and the result is the same.
Seems to only start working if I add the cocoapods plugin but according to this comment it shouldn't be needed
@franmontiel if you add the cocoapods plugin it will work because our gradle plugin detects this and installs the sentry-cocoa dependency via the cocoapods plugin.
can you show your kmp gradle config? in case you changed something
/path/to/iosApp/ doesnt seem right unless you purposefully changed the log
The /path/to/iosApp/ was just me modifying the path as it was irrelevant.
Here the gradle file as it is failing right now
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
id("io.sentry.kotlin.multiplatform.gradle") version "0.10.0"
}
kotlin {
androidTarget {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = false
}
}
sourceSets {
commonMain.dependencies {
//put your multiplatform dependencies here
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
android {
namespace = "io.bridify.sentrytest"
compileSdk = 35
defaultConfig {
minSdk = 24
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
Thanks! I was able to reproduce it.
The issue is that in newer versions the sentry-cocoa artifacts changed the folder names
- ios-arm64
- ios-arm64_x86_64-maccatalyst
- ios-arm64_x86_64-simulator
turned into
- ios-arm64_arm64e
- ios-arm64_arm64e_x86_64-maccatalyst
- ios-arm64_x86_64-simulator
I will add a fix for this
If you want to try it out for now you can for example use the sentry-cocoa version8.37.0 which will still be compatible
With version 8.37.0 the same thing is happening.
For what I am understanding we required the Sentry library to be build in a specific folder location (that I believe it does not coincide with the XCode default build folder). Could that be the cause?
I tried moving my DerivedData folder to a different place and using frameworkPath option to direct to the exact folder were the .xcframework was, is this the expected setup?
I tested it locally on a new project with 8.37.0 which works and 8.38.0 which doesnt work.
by default the gradle plugin will use the xcodeproj to determine where the build folder is located via xcodebuild -project yourproject.xcodeproj -showBuildSettings which spits out a bunch of info including BUILD_DIR which points to the derived data path of your build and thats where we are looking for the framework that you installed with SPM
if for some reason that deviates you'll need to update the frameworkPath configuration to point to that - that's the main purpose of this option so in your case it is expected although I am not sure in your case why the framework is not in the build folder that we receive from the xcodebuild command
can you paste here the location where the framework is by default? (before you moved it)
This is were the error message says it is looking for the frameworks
/Users/fj/AndroidStudioProjects/SentryTest/iosApp/build/SourcePackages/artifacts/sentry-cocoa/Sentry-Dynamic/Sentry-Dynamic.xcframework/ios-arm64
/Users/fj/AndroidStudioProjects/SentryTest/iosApp/build/SourcePackages/artifacts/sentry-cocoa/Sentry/Sentry.xcframework/ios-arm64
No matter where I configure Derived data and build folders location that it will always show me those locations in the error. It could mean that the code that find the frameworks is faulty or for some reason the error message is using a different path.
This is for me the default derived data folder were I can find the frameworks:
/Users/fj/Library/Developer/Xcode/DerivedData/Bridify-ddpfikekigqzzgcnpfnacsmlfpln/SourcePackages/artifacts/sentry-cocoa
I am also thinking, it is DerivedData folder reliable to depend on? Could it happen that the folder is deleted and we might end-up in a catch-22 situation where KMP project needs the framework files but those are not build because KMP part is failing?
yeah that doesn't look right
can you execute xcodebuild -project yourproject.xcodeproj -showBuildSettings and post the BUILD_DIR
we might end-up in a catch-22 situation where KMP project needs the framework files
if you update or reload the SPM package dependencies that should restore the framework files without you needing to actually compile the project
in any case this is a best effort solution since there is no official support for a Kotlin SPM plugin right now. if you manually set up the SDK you would also have to do these steps -> find the framework location and set up linking manually
can you execute
xcodebuild -project yourproject.xcodeproj -showBuildSettingsand post theBUILD_DIR
BUILD_DIR = /Users/fj/AndroidStudioProjects/SentryTest/iosApp/build
That's really weird, as if I check it from XCode it is inside DerivedData folder.
By the way, in my case, the SourcePackages is not in the build folder but in the DerivedData folder
BUILD_DIR = /Users/fj/AndroidStudioProjects/SentryTest/iosApp/build
hmm looks like this is the issue, on my end BUILD_DIR points to the derived data path location. tbh I'm unsure why it points to the build folder of your kmp app
in the output are there any other fields that point to the derived data? we might be able to use those as a fallback
For what I see there is no value that points to the DerivedData folder.
For the moment to make it work without needing to change my project configuration to use Cocoapods I've done the following:
- Manually added Sentry.xcframework (version 8.37.0 until the plugin is fixed) to the iOS project.
- Added sentry dependencies and plugin in my KMP project (Version 0.9.0 or you will face this issue)
- Configured Sentry in my KMP project build.gradle.kts file to point to the .xcframework file:
sentryKmp {
autoInstall {
linker {
frameworkPath.set(rootProject.file("iosApp/Frameworks/").absolutePath)
}
}
}
- Be sure that your KMP project is not a dynamic library,
isStatic = truemust be set
@buenaflor could you please let me know when the plugin is fixed so I can be able to use the latest version of the library? Thanks so much for your help
thanks for the info
I will look into a way to get the derived data path reliably and fix the folder name missmatch
that way you can use a higher cocoa version as well
Unlikely though that a fix will be out this week, most likely next monday
@franmontiel do you mind sending me the output of xcodebuild -project yourproject.xcodeproj -showBuildSettings to [email protected] so I can take a closer look
@franmontiel do you mind sending me the output of
xcodebuild -project yourproject.xcodeproj -showBuildSettingsto [email protected] so I can take a closer look
email sent.
update: I'm working on the fix as we speak, I'll see to it that it's out soon
Just a quick note here, sentry-kmp 0.10.0 is NOT compatible with sentry-cocoa 8.37.0 due to (atleast one) renamed api
You have to use sentry-kmp 0.9.0 with sentry-cocoa 8.36.0 for now.
You have to use sentry-kmp 0.9.0 with sentry-cocoa 8.36.0 for now.
Thanks for the info, yes right now until I release the gradle plugin fix I recommend this combination
@franmontiel just published 0.11.0, could you try out if it fixes the problem
@franmontiel just published 0.11.0, could you try out if it fixes the problem
Hi @buenaflor! Thank you for your work on this library.
I've tested out 0.11.0 and it doesn't fix the issue for me on iOS 😔 The app crashes when launching right after building (debug mode) with the following error:
dyld[xxxxx]: Library not loaded: @rpath/Sentry.framework/Sentry
Referenced from: /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-xxxxx/Build/Products/Debug-iphonesimulator/<AppName>.framework/<AppName>
Reason: tried: '/Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-xxxxx/Build/Products/Debug-iphonesimulator/Sentry.framework/Sentry' (no such file),
'/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/Sentry.framework/Sentry' (no such file),
'/usr/lib/swift/Sentry.framework/Sentry' (no such file),
'/Users/<username>/Library/Developer/CoreSimulator/Devices/<device-id>/data/Containers/Bundle/Application/<bundle-id>/AppNameApp.app/Frameworks/Sentry.framework/Sentry' (no such file)
[Additional paths omitted for brevity]
@remarkjt can you share your gradle config
@remarkjt can you share your gradle config
Here's my build.gradle.kts with sensitive info replaced with placeholders and irrelevant lines removed.
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.22"
kotlin("native.cocoapods")
id("com.android.library")
id("io.sentry.kotlin.multiplatform.gradle") version "0.11.0"
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "My SDK"
homepage = "..."
version = "x.y.z"
ios.deploymentTarget = "13.4"
framework {
baseName = "shared"
isStatic = true
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
// other dependencies...
}
}
// other sourcesets...
}
}
android {
namespace = "com.example.myapp"
compileSdk = 35
defaultConfig {
minSdk = 26
}
buildToolsVersion = "33.0.2"
ndkVersion = "24.0.8215888"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
Hi @buenaflor, for me the new plugin fixes the local build but now I am unable to build the iOS library using Github Actions. The build fails with the following error:
Plugin 'io.sentry.kotlin.multiplatform.gradle': failed to compute value with custom source 'io.sentry.kotlin.multiplatform.gradle.DerivedDataPathValueSource' with org.gradle.process.internal.ExecException: Process 'command 'xcodebuild'' finished with non-zero exit value 74
I've just created a new issue for this problem.
Closing this for now, let us know if you still have issues