Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for iOS build targets in KMM #1150

Open
nalexn opened this issue Dec 18, 2024 · 5 comments
Open

Support for iOS build targets in KMM #1150

nalexn opened this issue Dec 18, 2024 · 5 comments

Comments

@nalexn
Copy link

nalexn commented Dec 18, 2024

  • Version of the library: 0.21.0
  • Affected devices: -
  • Affected versions: -

Does the library support iosArm64() and iosSimulatorArm64() targets? I can see them defined in the gradle files, but when I'm trying to compile a KMM project I get the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':common:transformCommonMainDependenciesMetadata'.
> Could not resolve all dependencies for configuration ':common:iosArm64CompilationDependenciesMetadata'.
   > Could not find Emoji:emoji-iosarm64:unspecified.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/Emoji/emoji-iosarm64/unspecified/emoji-iosarm64-unspecified.pom
       - https://plugins.gradle.org/m2/Emoji/emoji-iosarm64/unspecified/emoji-iosarm64-unspecified.pom
       - https://jitpack.io/Emoji/emoji-iosarm64/unspecified/emoji-iosarm64-unspecified.pom
       - https://maven.fpregistry.io/releases/Emoji/emoji-iosarm64/unspecified/emoji-iosarm64-unspecified.pom
     Required by:
         project :common > com.vanniktech:emoji:0.21.0

I think I have misconfigured the dependency for iOS, but not sure where.

Portion of the libs.versions.toml file:

[versions]
emoji = "0.21.0"

emoji-google-compat = { group = "com.vanniktech", name = "emoji-google-compat", version.ref = "emoji" }
emoji-material = { group = "com.vanniktech", name = "emoji-material", version.ref = "emoji" }
emoji-core = { group = "com.vanniktech", name = "emoji", version.ref = "emoji" }

Portion of the build.gradle.kts file

kotlin {
    androidTarget {}
    jvm()
    listOf(
        iosArm64(),
        iosSimulatorArm64(),
    ).forEach {
        it.binaries.framework {
            baseName = "Common"
            isStatic = false
            binaryOption("bundleId", "com.blahblah.common")
        }
    }

    sourceSets {
        commonMain.dependencies {
            ...
        }
        jvmMain.dependencies {
            implementation(libs.emoji.google.compat)
        }
        androidMain.dependencies {
            implementation(libs.emoji.google.compat)
            implementation(libs.emoji.material)
        }
        iosMain.dependencies {
            implementation(libs.emoji.core)
        }
    }
}

And the code that tries to import and use it in commonMain. (FYI when the implementation is "actual"-ised in androidMain all compiles and works ok):

package com.blahblah.common.emoji

import com.vanniktech.emoji.emojiInformation

object EmojiManager {

    fun parse(input: String?): EmojiInformation {
        val result = input?.trim().emojiInformation()
        ...
    }
}
@vanniktech
Copy link
Owner

implementation(libs.emoji.core) should be in commonMain.dependencies

@nalexn
Copy link
Author

nalexn commented Dec 19, 2024

Oh, I mixed up the sample codes. Essentially - I tried that, it didn't compile either. So I got back to expect / actual per platform, that is:

        iosMain.dependencies {
            implementation(libs.emoji.core)
        }

for

// commonMain
package com.blahblah.common.emoji

expect object EmojiManager {
    fun parse(input: String?): EmojiInformation
}
// iosMain
package com.blahblah.common.emoji

import com.vanniktech.emoji.emojiInformation // error - unresolved symbol

actual object EmojiManager {
   ....
}

@vanniktech
Copy link
Owner

This should work though.

@nalexn
Copy link
Author

nalexn commented Dec 19, 2024

Could you maybe add an iOS target in the sample app in this repo? This way you could verify it's working, and also have a reference for others

@vanniktech
Copy link
Owner

I currently don't have the time but yes, ideally this should be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants