Summary
When adding starknet.swift to a project that also depends on swift-sodium, the build fails with a duplicate output error for module.modulemap.
Steps to Reproduce
- Create a macOS Command Line Tool (Swift) in Xcode.
- Add dependencies:
- software-mansion/starknet.swift
- jedisct1/swift-sodium
- Build.
Actual Results
Build fails with:
- warning: duplicate output file '.../Build/Products/Debug/include/module.modulemap'
- error: Multiple commands produce '.../Build/Products/Debug/include/module.modulemap'
- Command: ProcessXCFramework .../starknet.swift/Frameworks/CryptoRs.xcframework ...
- Command: ProcessXCFramework .../swift-sodium/Clibsodium.xcframework ...
Expected Results
Project builds without errors.
Root Cause (analysis)
Both packages ship a binary target with a top-level Headers/module.modulemap. SwiftPM/Xcode flattens Headers/* from binary targets into a shared Build/Products/<config>/include/ directory. That causes both packages to try to write include/module.modulemap, producing the collision.
Proposed Fix
Relocate CryptoRs’ module map into Modules/module.modulemap (per Clang/Swift conventions) and reference headers relatively:
module CryptoRs {
header "../Headers/crypto-rs.h"
export *
}