s

    Sachinda Liyanaarachchi

    1 month ago
    hello, I have a question related to KMM shared gradle: There is one library that is related to fritz2 but should be added in commonMain dependencies. But when I run ios it is giving me an error. How can I leave this library in commonMain and exclude it when running ios?
    * What went wrong:
    Execution failed for task ':shared:compileKotlinIosSimulatorArm64'.
    > Could not resolve all files for configuration ':shared:iosSimulatorArm64CompileKlibraries'.
       > Could not resolve dev.fritz2:core:1.0-RC1.
         Required by:
             project :shared
          > No matching variant of dev.fritz2:core:1.0-RC1 was found. The consumer was configured to find a usage of 'kotlin-api' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_simulator_arm64' but:
              - Variant 'jsIrApiElements-published' capability dev.fritz2:core:1.0-RC1 declares a usage of 'kotlin-api' of a library:
                  - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
              - Variant 'jsIrRuntimeElements-published' capability dev.fritz2:core:1.0-RC1 declares a library:
                  - Incompatible because this component declares a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
              - Variant 'jsLegacyApiElements-published' capability dev.fritz2:core:1.0-RC1 declares a usage of 'kotlin-api' of a library:
                  - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
              - Variant 'jsLegacyRuntimeElements-published' capability dev.fritz2:core:1.0-RC1 declares a library:
                  - Incompatible because this component declares a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
              - Variant 'jvmApiElements-published' capability dev.fritz2:core:1.0-RC1 declares an API of a library:
                  - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
              - Variant 'jvmRuntimeElements-published' capability dev.fritz2:core:1.0-RC1 declares a runtime of a library:
                  - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
              - Variant 'metadataApiElements' capability dev.fritz2:core:1.0-RC1 declares a usage of 'kotlin-api' of a library:
                  - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
                  - Other compatible attributes:
                      - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                      - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_simulator_arm64')
    Paul Woitaschek

    Paul Woitaschek

    1 month ago
    You can't. CommonMain is the parent source sets for all other source sets. You should use that library only in jvmMain or where ever you need it.