Flutter macos duplicate camera plugin

From divinevideo/divine-mobile · View interactive version

Flutter macos duplicate camera plugin is an AI agent skill from the GitHub repository divinevideo/divine-mobile. Fix Flutter macOS build failure caused by duplicate camera plugins. Use when: (1) macOS build fails with "Ambiguous use of 'CameraMacosPlugin.register(with:)'" error, (2) Both camera_macos and camera_macos_plus are in pubspec.yaml, (3) Build worked before adding a new camera package. The plugins def

How to use this skill

Skill file

Flutter macOS Duplicate Camera Plugin Fix

Problem

Flutter macOS builds fail when both camera_macos and camera_macos_plus packages are present

in pubspec.yaml. Both packages define the same CameraMacosPlugin class, causing Swift

registration ambiguity.

Context / Trigger Conditions

Error message:

Ambiguous use of 'CameraMacosPlugin.register(with:)'

Symptoms:

Common scenarios:

Solution

  1. Identify the duplicates - Check pubspec.yaml for both packages:

```yaml

# Look for these:

camera_macos: ^0.0.9

camera_macos_plus: ^0.0.3

```

  1. Choose one to keep - camera_macos_plus is generally preferred as it's a

more feature-complete fork of camera_macos

  1. Remove the duplicate from pubspec.yaml:

```yaml

# Keep only one:

camera_macos_plus: ^0.0.3 # macOS camera support

```

  1. Clean thoroughly - The Xcode build system may be in a corrupted state:

```bash

flutter clean

rm -rf build/

rm -rf macos/Pods/

rm -f macos/Podfile.lock

rm -rf ~/Library/Developer/Xcode/DerivedData/Runner-*

flutter pub get

```

  1. Rebuild:

```bash

flutter build macos

```

Verification

After the fix:

Example

Before (broken):

dependencies:
  camera_macos_plus: ^0.0.3
  divine_camera:
    path: packages/divine_camera
  camera_macos: ^0.0.9  # DUPLICATE - causes conflict

After (fixed):

dependencies:
  camera_macos_plus: ^0.0.3  # macOS camera support (replaces camera_macos)
  divine_camera:
    path: packages/divine_camera
  # camera_macos removed

Notes

thorough cleaning (including DerivedData) may be required

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.