ge-org / multiplatform-swiftpackage

Gradle plugin that generates a Swift Package Manager manifest and an XCFramework to distribute a Kotlin Multiplatform library for Apple platforms.
Apache License 2.0
337 stars 49 forks source link

Build failing: symbol(s) not found for architecture arm64 #46

Open surajsau opened 2 years ago

surajsau commented 2 years ago

I'm trying to create a SPM from a module which contains a simple object file.

object Strings {
    val TitleTalks = "Talks"
    val TabTalks = "Talks"
    val TabChannels = "Channel"
    val TabProfile = "Profile"
}

complete build.gradle looks like this

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3"
}

kotlin {
    multiplatformSwiftPackage {
        swiftToolsVersion("5.3")
        targetPlatforms {
            iOS { v("13") }
        }
        packageName("AppStrings")
        outputDirectory(File(projectDir, "spm/strings"))
    }

    android()

    ios {
        binaries {
            framework {
                baseName = "strings"
                isStatic = false
            }
        }
    }

    iosSimulatorArm64 {
        binaries {
            framework {
                baseName = "strings"
                isStatic = false
            }
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(libs.moko.resources.core)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation(libs.moko.resources.compose)
            }
        }
        val androidTest by getting

        val iosMain by getting
        val iosTest by getting
        val iosSimulatorArm64Main by getting {
            dependsOn(iosMain)
        }
        val iosSimulatorArm64Test by getting {
            dependsOn(iosTest)
        }
    }
}

android {..}

But I always get the following build error whenever I try accessing Strings.xx inside my Swift file

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_StringsStrings", referenced from:
      objc-class-ref in ContentView.o
ld: symbol(s) not found for architecture arm64
スクリーンショット 2022-09-07 8 58 21
melisa-dlg commented 1 year ago

Hi! I'm getting the same error, is there any update on this issue?

meekotherogue commented 1 year ago

Hey there, me too! 👋 Any update?

DevSrSouza commented 1 year ago

Did you folks try this version? id("io.github.luca992.multiplatform-swiftpackage") version "2.0.5-arm64"

luca992 commented 1 year ago

https://github.com/ge-org/multiplatform-swiftpackage/pull/41#issuecomment-1376051526