Skip to content

Package.swift missing from npm package (breaks Capacitor 8 SPM projects) #312

@productdevbook

Description

@productdevbook

Problem

Package.swift exists in the GitHub repository but is not included in the npm package because it's missing from the files field in package.json.

Evidence

The package.json files field currently only includes:

"files": [
  "CapgoCameraPreview.podspec",
  "android/",
  "dist/",
  "ios/"
]

Package.swift is absent, so when Capacitor CLI runs cap sync, it warns:

[warn] @capgo/camera-preview does not have a Package.swift
[warn] Some installed packages are not compatible with SPM

And the plugin is excluded from the generated CapApp-SPM/Package.swift, causing a runtime error on iOS:

Error: "CameraPreview" plugin is not implemented on ios

Reproduction

  1. Create a Capacitor 8 project using SPM (default for Cap 8)
  2. npm install @capgo/camera-preview
  3. npx cap sync ios
  4. Observe the warning and that @capgo/camera-preview is missing from CapApp-SPM/Package.swift

Fix

Add Package.swift to the files array in package.json:

"files": [
  "Package.swift",
  "CapgoCameraPreview.podspec",
  "android/",
  "dist/",
  "ios/"
]

Workaround

Manually copy Package.swift from the repo root into node_modules/@capgo/camera-preview/ after install. After doing this, cap sync picks it up correctly:

[info] All plugins have a Package.swift file and will be included in Package.swift
       @capgo/camera-preview@8.1.1

Environment

  • @capgo/camera-preview: 8.1.1
  • @capacitor/core: 8.1.0
  • Capacitor CLI: 8.x
  • Package manager: pnpm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions