Add Swift Package Manager Adapter for`tuist inspect implicit-imports

Proposal: Add Swift Package Manager Adapter for `tuist inspect implicit-imports’

Summary

Add support for pure Swift Package Manager (SPM) projects to the tuist inspect implicit-imports command by implementing an SPM adapter. This will allow Tuist to detect implicit dependencies in Swift Package projects without requiring Tuist manifest files.

Motivation

Currently, the tuist inspect implicit-imports command only works with Tuist-managed projects. However, many Swift developers use pure SPM projects without Tuist manifests.

Proposed Solution

Architecture Overview

The implementation follows the existing adapter pattern used in the reference implementation ([ImplicitChecker]( GitHub - rofle100lvl/ImplicitChecker )). The solution involves:

  1. SPM Adapter A new adapter that uses swift package describe --type json to extract package information

  2. Integration: Plug the adapter into the existing inspect implicit-imports flow

  3. Minimal changes: Reuse existing implicit import detection logic

Implementation Details

  1. SPM Adapter Component

Create a new SPMProjectAdapter that:

  • Detects if the current directory contains a Package.swift file

  • Executes swift package describe --type json to get package metadata

  • Parses the JSON output to extract target information

  • Converts SPM target descriptions to Tuist’s internal graph representation

  1. SPM Package Description Models

Define models to parse swift package describe JSON output:

struct SPMPackageDescription: Codable {

let targets: [SPMTargetDescription]

}

struct SPMTargetDescription: Codable {
let name: String
let sources: [String]
let path: String
let targetDependencies: [String]
let productDependencies: [String]
}

  1. Integration Points

Location: Sources/TuistKit/Services/InspectImplicitImportsService.swift\

The service should:

  1. Detect project type (Tuist manifest vs SPM). By default it would be tuist, but if there is no tuist project in the folder - than SPM

  2. Use appropriate adapter to load project structure

  3. Run existing implicit import detection logic

  4. Report findings

#### 4. Reuse Existing Logic

The core implicit import detection logic can be reused:

  1. Target scanning: Scan source files for import statements

  2. Dependency analysis: Compare imported modules against declared dependencies

  3. Reporting: Use existing error reporting mechanisms

Example Usage

# For SPM projects

cd MySwiftPackage

tuist inspect implicit-imports

# For Tuist projects (existing behavior)

cd MyTuistProject

tuist inspect implicit-imports

### Expected Output

```

Inspecting implicit imports…

✗ Found implicit dependencies:

- NetworkModule implicitly depends on: CoreModule

- UIModule implicitly depends on: CoreModule, NetworkModule

Run ‘swift package edit’ to add missing dependencies.

```

Or on success:

```

✓ No implicit dependencies found in your project.

```

## References

- Reference implementation: [ImplicitChecker]( GitHub - rofle100lvl/ImplicitChecker )

-–

**Author**: @rofle100lvl

**Date**: 2025-12-05

This looks good to me. Thoughts @marekfort / @cschmatzler ?

Thanks for writing this up!

We might be able to take inspiration from this project that renders a graph for SwiftPM-only projects. In fact, our tuist graph could be adapted to support SwiftPM-only projects, too.

@rofle100lvl have you also thought about what would support look like for Xcode projects with local SwiftPM packages, which is a very common setup?

Otherwise, aligned with the proposal :slightly_smiling_face: