I’ve encountered an issue while working with a Kotlin Multiplatform (KMP) project and Swift Package Manager (SPM). I have a simple dummy KMP Swift Package available at this repository.
The goal is to use this package in another Swift project managed by SPM, which can be found here.
The process begins smoothly with the command swift build:
Fetching https://github.com/atonamy/kmp-spm-example.git from cache
Fetched https://github.com/atonamy/kmp-spm-example.git (0.89s)
Computing version for https://github.com/atonamy/kmp-spm-example.git
Computed https://github.com/atonamy/kmp-spm-example.git at 0.0.1 (1.07s)
Creating working copy for https://github.com/atonamy/kmp-spm-example.git
Working copy of https://github.com/atonamy/kmp-spm-example.git resolved at 0.0.1
Building for debugging..
However, if I change the command with this new command:
swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "arm64-apple-ios16.4-simulator"
I’ll stumble with this weird error:
Sources/TestSPM/TestSPM.swift:2:8: error: no such module 'spm'
import spm
Interestingly, when I integrate the same package into a regular .xcodeproj, it functions correctly without any issues (with target ios16.4-simulator). This leads me to wonder why it fails to be recognized when used within a SPM project.
Has anyone else experienced this, or does anyone have insights on why this might be happening and how to resolve it?




