Redefinition of module 'FFI'
litewrap opened this issue · comments
Describe the bug
macOS 13.6.6
Xcode 15.2
Building Adwaita Swift Pkg give the following error:
Redefinition of module 'FFI'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/ffi/module.modulemap:1:8 Redefinition of module 'FFI'
Homebrew and libffi on my M1 mac:
admin@mbam1 ~ % which pkg-config
/opt/homebrew/bin/pkg-config
admin@mbam1 ~ % pkg-config --cflags libffi
-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi
I found this same issue previously reported in Homebrew and SwiftPM sites by user having same clash problem
when they try building swift-systemlib-demo.
Related links:
Strange clash between Xcode and command-line tools when building Swift system library package #4025
https://github.com/orgs/Homebrew/discussions/4025
Patch *.sdk paths from pkgConfig files to the current SDK #6772
swiftlang/swift-package-manager#6772
See details here: swiftlang/swift-package-manager#6439
I give a try to compile the Swift package swift-systemlib-demo and its fine without error.
As explained in This package that was used by the SwiftPM team to reproduce the error and test their fix.
It just strange the error re-appear when building Adwaita for Swift.
Any idea ?
To Reproduce
Download the Swift package and
swift build
Expected behavior
Build success
Additional context
Building for debugging...
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/ffi/module.modulemap:1:8: error: redefinition of module 'FFI'
module FFI [system] {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi/module.modulemap:1:8: note: previously defined here
module FFI [system] [extern_c] {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/ffi/module.modulemap:1:8: error: redefinition of module 'FFI'
module FFI [system] {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi/module.modulemap:1:8: note: previously defined here
module FFI [system] [extern_c] {
Thanks for opening the issue, @litewrap! I experienced this as well when testing on macOS. Here is what works for me:
- Clean the build folder (Xcode:
Product > Clean Build Folder...
). - Reset package caches (Xcode:
File > Packages > Reset Package Caches
) - Delete the
DerivedData
folder (~/Library/Developer/Xcode/DerivedData
) - Run the following command in a terminal:
sed -i '' 's/-I..includedir.//g' $(brew --prefix)/Library/Homebrew/os/mac/pkgconfig/*/libffi.pc
- Resolve package versions (Xcode:
File > Packages > Resolve Package Versions
) - Run the app. Now, it succeeds.
I'm not sure whether every step is strictly necessary. Does that help in your case?
I first experienced this problem here: stackotter/swift-cross-ui#47
Does that help in your case?
Yes package build success !
Thanks David and bravo for this great package !!
Nice! While libadwaita works on macOS, I recommend using Linux for the best experience. I recommend trying Asahi Linux. Thanks for opening the issue!
Thank you!