Safeguard
Developer Tools•

How do you scan dependencies in a Kotlin Multiplatform project?

Kotlin Multiplatform declares dependencies per source set across Gradle and SwiftPM. Learn how to build one inventory so iOS and Android are both covered.

Safeguard Security Team
3 min read

Scan each source set, not just the module. In Kotlin Multiplatform, dependencies are declared per source set such as commonMain, androidMain and iosMain, and native dependencies come from Gradle for Android and Swift Package Manager for iOS. Build one inventory that merges all of them.

How KMP declares dependencies

Per the Kotlin documentation, you add each dependency to a specific source set. There are two kinds.

KindWhere declaredExample use
Multiplatform dependencycommonMainA library that supports every target
Native dependencyandroidMain, iosMainPlatform APIs

A dependency in commonMain is available to all source sets, and the plugin resolves the matching platform artifacts. Every source set also depends on kotlin-stdlib automatically, at the version of the Kotlin Multiplatform Gradle plugin. The docs recommend a version catalog.

Where scanning goes wrong

  • A scan of the Android module alone misses what iosMain pulls in.
  • A scan of the iOS app alone misses the shared Kotlin code compiled into it.
  • Native iOS dependencies declared outside Gradle live in a different file than the rest.

Build one inventory

  1. List the Gradle dependencies for each source set and target, including test sets separately.
  2. List the SwiftPM or other iOS package dependencies used by the iOS app and any Kotlin interop.
  3. Note the Kotlin plugin version, since the standard library follows it.
  4. Merge the lists with a column for where each dependency is used.
  5. Check each against known advisories.
  6. Decide ownership. A shared library fix touches both platforms, so one person should coordinate.
  7. Pin versions in a catalog so Android and iOS builds use the same values.

For the platform halves, see how to list every dependency in an Android Gradle app and in an iOS app.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how one inventory can bring several package sources together.

Safeguard builds an SBOM and scans your dependencies for known vulnerabilities, and you can run a free scan at gold.safeguard.sh/scan to see what your own project pulls in.

Quick check

Does a commonMain dependency reach iOS?

Yes. A dependency in commonMain is available to all source sets, and the plugin resolves the platform variant.

Is the Kotlin standard library a dependency I need to track?

Yes. It is added automatically to every source set, at the version of the Kotlin Multiplatform Gradle plugin.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.