I'm trying to consume a swift package in the iOS s...
# multiplatform
a
I'm trying to consume a swift package in the iOS side of my KMP project, but when I try to build I get weird linker errors. I'm wondering if maybe the kmp configuration isn't targeting enough ios build targets or something. Has anyone gotten something like this to work? For reference, all I am doing is adding this library: https://github.com/devicekit/DeviceKit and then importing & using the basic functionality in a swift file. I get errors like:
Copy code
ld: Undefined symbols:
  DeviceKit.Device.isPad.getter : Swift.Bool,

clang: error: linker command failed with exit code 1 (use -v to see invocation)
Anyone seen something similar?
l
What does your def file look like? Usually, linker errors like this mean that the library is dynamically linked, and you don't include the binary for the library in the app, but it's hard to tell without more info.
a
So in this case it's a third party library added via Swift Package Manager in Xcode. Then I do a simple import & call to a static class. I thought it should be pretty simple and straightforward but get the linker error.
Which makes me wonder if KMP isn't building enough targets that the library expects or something
l
Also, it looks like this is a pure-swift library with no Obj-C markings. Are you calling this from Kotlin or Swift?
a
Swift!
l
I remember there being an extra step in XCode to get the library to actually be placed in the app binary, but I don't remember the specifics offhand. I'd recommend checking the linker settings. In either case, I don't think KMP would be involved in the issue, since it's Swift code consuming Swift code.
a
Yeah I'm very noobish wrt iOS dev, so I am very possibly missing something very basic. Thanks for the tip!