<#C3PQML5NU|multiplatform> Hello Guys, I am creati...
# multiplatform
r
#multiplatform Hello Guys, I am creating multiplatform library for iphone . in build.gradle i have
Copy code
kotlin {
    android()
  
  
    iosArm64("native") {
        binaries {
            framework {
                baseName = "Demo"
            }
        }
    }

 sourceSets {
        val commonMain by getting {
          
                implementation("de.voize:pytorch-lite-multiplatform:0.5.0")
            
            }
        }
}
 while generating framework I am getting following error
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_TorchModule", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_Tensor", referenced from:
      objc-class-ref in result.o
  "_OBJC_CLASS_$_IValueWrapper", referenced from:
      objc-class-ref in result.o
ld: symbol(s) not found for architecture arm64
Given library is multiplatform library
Can anybody help?
k
You need to finish the install instructions from https://github.com/voize-gmbh/pytorch-lite-multiplatform. Specifically,
Copy code
cocoapods {
    ...

    pod("PLMLibTorchWrapper") {
        version = "<version>"
    }

    useLibraries()
}
Undefined symbols for architecture arm64:
means you have a linking issue. Specifically that the linker expects native binary that doesn’t exist.
Now, I would argue the library might want to consider packaging that in the library, but that is a fairly advanced thing to do, and may not be desired depending on how the underlying native library is used.
r
If this is the case then what is the benifit of using multiplatform library
k
You can call the library from Kotlin
So, for Crashlytics integration, we don’t package Crashlytics because the host iOS app probably wants to control that. For QuickJS in zipline (https://github.com/cashapp/zipline/) we do, because the host app is unlikely to use it directly and wouldn’t want to deal with the details.
r
I have added
Copy code
pod("PLMLibTorchWrapper") {
        version = "<version>"
    }

    useLibraries()
still facing the same issue
k
You’ll need more detail. Where are you facing the same issue? What task? During the Xcode build? Is it when Kotlin is compiling or when you’re trying to build the app? did you convert your build to use cocoapods plugin rather than specifying the framework binaries directly? There’s a basic understanding of iOS dev you’ll need to start using iOS dependencies like this. Your underlying problem is what I’ve said. You have linking issues with your dependency. This isn’t (really) a KMM thing, although again, the library publishing may be able to make packaging easier, but that’s a discussion with the library publisher. I gave sort of a deep dive on cinterop earlier this year: https://www.droidcon.com/2022/06/28/sdk-design-and-publishing-for-kotlin-multiplatform-mobile/