Skip to content

Xcode build fails with duplicate embed errors for Turf, MapboxCoreMaps & MapboxCommon when integrating Mapbox Navigation v3 via SPM alongside @rnmapbox/maps CocoaPods #4761

Open
@mafaqriaz

Description

@mafaqriaz

Description
When I add the Mapbox Navigation SDK v3 (via Swift Package Manager) into an existing React Native iOS project that already uses rnmapbox-maps (via CocoaPods), the Xcode 15 build fails with “Multiple commands produce” errors for Turf.framework, MapboxCoreMaps.framework and MapboxCommon.framework. I’ve tried patching the CocoaPods embed script and looking for an “Embed Swift Package Libraries” phase to disable, but nothing stops the duplicate-embed.

Steps to Reproduce

  1. Setup React Native map:
  • Add rnmapbox-maps to your Podfile and run pod install.
  1. Add Navigation via SPM:
  1. Configure tokens & permissions (per Mapbox docs)
  2. Build in Xcode 15 (macOS Sonoma)

You will see errors like:

Multiple commands produce '/…/Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Turf.framework'
Multiple commands produce '/…/Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/MapboxCoreMaps.framework'
Multiple commands produce '/…/Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/MapboxCommon.framework'

What I Expected

  • Each framework should be embedded only once (either via CocoaPods or via SPM)
  • Build succeeds without manual script hacks

What Happened Instead

  • CocoaPods’ [CP] Embed Pods Frameworks phase and Xcode’s SPM embed phase both try to copy the same frameworks.
  • Attempts to patch Pods-MyApp-frameworks.sh to skip those frameworks did not resolve the “Multiple commands produce” errors.
  • I do not see any “Embed Swift Package Libraries” or “Embed Package Products” phase in my target’s Build Phases to disable.

Build Log Snippet

error: Multiple commands produce '/…/Frameworks/Turf.framework'
note: Target 'MyApp' has copy command from '…/Turf.xcframework/ios-arm64_x86_64-simulator/Turf.framework' to '/…/Frameworks/Turf.framework'
note: That command depends on command in Target 'MyApp': script phase “[CP] Embed Pods Frameworks”
...

Image

Attempts at a Fix

  • Patching install_framework() in Pods-MyApp-frameworks.sh to return early for Turf/MapboxCoreMaps/MapboxCommon
  • Searching for and disabling any SPM embed phase in Xcode UI

None have eliminated the duplicate-embed errors.

Request
Could you advise on the official way to integrate Mapbox Navigation v3 via SwiftPM and rnmapbox-maps via CocoaPods in the same project, so that Turf, MapboxCoreMaps and MapboxCommon are only embedded once and the build succeeds?

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