System library wrapper does not build on macOS 13 due to module redefinition errors

Hi everyone, apologies if this is the wrong place to ask.

I'm currently debugging a problem where building a Swift package wrapping a system library errors on macOS 13 (Xcode 14.1, Swift 5.7, with Homebrew installed) with the following message:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/ffi/module.modulemap:1:8: error: redefinition of module 'FFI'
module FFI [system] [extern_c] {
       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi/module.modulemap:1:8: note: previously defined here
module FFI [system] [extern_c] {

The issue, from what I understand, is that the compiler tries to include both the Xcode header and the command-line tools header for libffi, causing a clash. A little bit of googling lead me to the following threads with similar issues, suggesting it might be an issue with Homebrew:

Still, this feels like a strange issue. I've put together a simple example project that builds fine on Ubuntu, but errors on macOS (the GitHub Actions workflows confirm this):

https://github.com/fwcd/swift-systemlib-demo

The Xcode include seems to be coming from the Foundation import in SystemlibDemo.swift (removing it fixes the build) and the command-line tools include I am not sure about. Running pkg-config --cflags libffi yields

-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi

which seems to be coming from /opt/homebrew/Library/Homebrew/os/mac/pkgconfig/13/libffi.pc:

homebrew_sdkroot=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk
prefix=${homebrew_sdkroot}/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
toolexeclibdir=${libdir}
includedir=${prefix}/include/ffi

Name: libffi
Description: Library supporting Foreign Function Interfaces
Version: 3.4-rc1
Libs: -L${toolexeclibdir} -lffi
Cflags: -I${includedir}

Any ideas or suggestions on where my configuration went wrong or how to solve this module clash?