https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Simon Buechner

09/26/2023, 12:52 PM
Hi, i am using kotlin multiplatform and i need to use a cocoapods library (IOSDFULibrary from nordic) and at the same time i need my project to create a xcframework. from what i read here, i can only use cocoapods or xcframework. Is there a way to use a cocoapod in multiplatform without using cocoapods in build.gradle? Or is there another way how i can do this? on kotlin 1.7.20 doing both at the same time works, but now i am forced to upgrade to 1.9.10 if i want to use the latest xcode version. Any thoughts or ideas for this problem?
k

Konstantin Tskhovrebov

09/26/2023, 1:07 PM
No. It's independent things. You can use the cocoapods plugin to integrate 3d party deps to your project. And build your kotlin project as a xcframework at the same time
s

Simon Buechner

09/26/2023, 1:08 PM
if i try i get the unique attributes error, that says i need to add a dummy attribute but i dont even know where and how i should add this.
k

Konstantin Tskhovrebov

09/26/2023, 1:12 PM
Have you tried to build a xcframework by the cocoapods plugin provided task? https://kotlinlang.org/docs/multiplatform-build-native-binaries.html
s

Simon Buechner

09/26/2023, 1:12 PM
i have something like this:
Copy code
iosX64()
iosArm64()

cocoapods {
    ios.deploymentTarget = "13.0"

    summary = "Some description for a Kotlin/Native module"
    homepage = "Link to a Kotlin/Native module homepage"

    podfile = project.file("../MyProject_iOS/Podfile")
    pod("iOSDFULibrary") {
        version = "4.13.0"
    }

    framework {
        baseName = "MyProject"
        isStatic = true
    }
}

val xcf = XCFramework()
val iosTargets = listOf(iosX64(), iosArm64())

iosTargets.forEach {
    it.binaries.framework {
        baseName = "MyProject"
        xcf.add(this)
    }
}
which ends in an: Consumable configurations with identical capabilities within a project (other than the default configuration) must have unique attributes. Thanks for your help @Konstantin Tskhovrebov
k

Konstantin Tskhovrebov

09/26/2023, 1:12 PM
Screenshot_2023-09-26-15-12-21-90_ffb2f5e1b976ff98cfc94f359fbce8de.jpg
s

Simon Buechner

09/26/2023, 1:14 PM
i got problems with those tasks: sharedpodDebugFrameworkIosFat' and [configuration 'shareddebugFrameworkIosFat'] if i kill the cocoapods or the xcframework it works
k

Konstantin Tskhovrebov

09/26/2023, 1:16 PM
Could you share the exact error log? I don't understand the problem
s

Simon Buechner

09/26/2023, 1:17 PM
Sure here it is:
Could not determine the dependencies of task ':shared:transformAppleMainCInteropDependenciesMetadataForIde'.
Could not resolve all dependencies for configuration 'sharedappleMainResolvableDependenciesMetadata'.
> Consumable configurations with identical capabilities within a project (other than the default configuration) must have unique attributes, but configuration 'sharedpodDebugFrameworkIosFat' and [configuration 'shareddebugFrameworkIosFat'] contain identical attribute sets. Consider adding an additional attribute to one of the configurations to disambiguate them. Run the 'outgoingVariants' task for more details. See https://docs.gradle.org/8.0/userguide/upgrading_version_7.html#unique_attribute_sets for more details. * Try:
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
* Exception is: org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task 'sharedtransformAppleMainCInteropDependenciesMetadataForIde'. at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:68) at org.gradle.execution.plan.TaskDependencyResolver.resolveDependenciesFor(TaskDependencyResolver.java:49) at org.gradle.execution.plan.LocalTaskNode.getDependencies(LocalTaskNode.java:147) at org.gradle.execution.plan.LocalTaskNode.resolveDependencies(LocalTaskNode.java:121) at org.gradle.execution.plan.DefaultExecutionPlan.discoverNodeRelationships(DefaultExecutionPlan.java:184) at org.gradle.execution.plan.DefaultExecutionPlan.doAddEntryNodes(DefaultExecutionPlan.java:156) at org.gradle.execution.plan.DefaultExecutionPlan.addEntryTasks(DefaultExecutionPlan.java:131) at org.gradle.execution.plan.DefaultExecutionPlan.addEntryTasks(DefaultExecutionPlan.java:123) at org.gradle.execution.TaskNameResolvingBuildTaskScheduler.scheduleRequestedTasks(TaskNameResolvingBuildTaskScheduler.java:53) at org.gradle.execution.DefaultTasksBuildTaskScheduler.scheduleRequestedTasks(DefaultTasksBuildTaskScheduler.java:72) at org.gradle.initialization.DefaultTaskExecutionPreparer.lambda$scheduleRequestedTasks$0(DefaultTaskExecutionPreparer.java:46) at org.gradle.internal.Factories$1.create(Factories.java:31) at org.gradle.internal.work.DefaultWorkerLeaseService.withReplacedLocks(DefaultWorkerLeaseService.java:345) at org.gradle.api.internal.project.DefaultProjectStateRegistry$DefaultBuildProjectRegistry.withMutableStateOfAllProjects(DefaultProjectStateRegistry.java:227) at org.gradle.api.internal.project.DefaultProjectStateRegistry$DefaultBuildProjectRegistry.withMutableStateOfAllProjects(DefaultProjectStateRegistry.java:220) at org.gradle.initialization.DefaultTaskExecutionPreparer.scheduleRequestedTasks(DefaultTaskExecutionPreparer.java:45) at org.gradle.initialization.VintageBuildModelController.lambda$scheduleRequestedTasks$0(VintageBuildModelController.java:76) at org.gradle.internal.model.StateTransitionController.lambda$inState$2(StateTransitionController.java:121) at org.gradle.internal.model.StateTransitionController.lambda$inState$3(StateTransitionController.java:136) at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44) at org.gradle.internal.model.StateTransitionController.inState(StateTransitionController.java:132) at org.gradle.internal.model.StateTransitionController.inState(StateTransitionController.java:120) at org.gradle.initialization.VintageBuildModelController.scheduleRequestedTasks(VintageBuildModelController.java:76) at org.gradle.internal.build.DefaultBuildLifecycleController$DefaultWorkGraphBuilder.addRequestedTasks(DefaultBuildLifecycleController.java:260) at org.gradle.internal.buildtree.DefaultBuildTreeWorkPreparer.lambda$scheduleRequestedTasks$0(DefaultBuildTreeWorkPreparer.java:38) at org.gradle.internal.build.DefaultBuildLifecycleController.lambda$populateWorkGraph$4(DefaultBuildLifecycleController.java:148) at org.gradle.internal.build.DefaultBuildWorkPreparer.populateWorkGraph(DefaultBuildWorkPreparer.java:42) at org.gradle.internal.build.BuildOperationFiringBuildWorkPreparer$PopulateWorkGraph.populateTaskGraph(BuildOperationFiringBuildWorkPreparer.java:120) at org.gradle.internal.build.BuildOperationFiringBuildWorkPreparer$PopulateWorkGraph.run(BuildOperationFiringBuildWorkPreparer.java:91) at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29) at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66) at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59) at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner
k

Konstantin Tskhovrebov

09/26/2023, 1:18 PM
What is kotlin version you use?
s

Simon Buechner

09/26/2023, 1:18 PM
at the moment 1.9.10
k

Konstantin Tskhovrebov

09/26/2023, 1:20 PM
Hmm. @a-dd do you know the reason for that? @Simon Buechner could you delete the xcframwork config from your script and try to run the task again?
s

Simon Buechner

09/26/2023, 1:21 PM
yes sure. it successfully builds.
it then even creates a fat-framework but if i try to use that, it wont work anymore like if i build it with the xcframework config.
k

Konstantin Tskhovrebov

09/26/2023, 1:23 PM
You don't need the fatframework if there is the xcframework
Right?
s

Simon Buechner

09/26/2023, 1:26 PM
the thing is, i always only used the fat-framework but i needed to use the xcframework plugin that the fat-framework could be used in the xamarin project.
I am so sorry for waisting your time a bit @Konstantin Tskhovrebov. The previous Developer inserted the xcframework but only used the fat framework... it perfectly works just with fat framework and i dont need the xcframework. But im pretty sure cocoapods and the xcframework setup at the same time doesnt work simultaniously. Thanks for your fast help, because of this i could now clean the code from unnecessary stuff and update to the latest kotlin version.
16 Views