Can't run TestFoundation target in swift-corelibs-foundation repository

I am starting contributing Swift Foundation framework. I am using swift-corelibs-foundation repository by following this guide: swift-corelibs-foundation/GettingStarted.md at main · apple/swift-corelibs-foundation · GitHub

But it is failed when I try to run TestFoundation:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include/fts.h:71:9: '(anonymous)' has different definitions in different modules; definition in module 'CoreFoundation' is here
swift-corelibs-foundation/CoreFoundation/Base.subproj/module.map:1:8: Redefinition of module 'CoreFoundation'
swift-corelibs-foundation/CoreFoundation/String.subproj/CFString.h:835:127: Reference to 'kCFStringEncodingASCII' is ambiguous
Could not build Objective-C module 'CoreGraphics'

Here is screenshot:

After these steps it is succeed:

  1. Clean
  2. Build
  3. Run Cmd-R

I have found another solution from here also:

  • swiftc does not order include paths. This means that build artifact module.modulemap and the installed module.modulemap will conflict with each other. To work around the issue while developing Foundation, remove /usr/local/include/CoreFoundation/module.modulemap before building.

Hi @shohin,
I am also trying to contribute, but finding it really hard just to run the tests on macOS using Xcode 13.1.

I am getting the same error as you, but cleaning, building and running didn't work out for me.

Nor does the workaround since the conflicting modulemap is not under /usr/local/include/CoreFoundation, but under /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Modules - and renaming or moving this file causes a whole lot of other issues.

Might you have any other pointers for running the tests?

+1 for the same issue

I am also running into this, using swift-DEVELOPMENT-SNAPSHOT-2022-03-22-a with Xcode 13.2.1. Is there a fix for this?

I'm seeing the same problem, where the test target will not build.

Running the 3-30-22 snapshot in Xcode 13.3 on an M1.

swift-project/swift-corelibs-foundation/CoreFoundation/Base.subproj/module.map:1:8: Redefinition of module 'CoreFoundation'

Could not build Objective-C module 'CoreGraphics'

Glad to know it isn't just me. I have the same issue with conflicting modulemaps coming from the SDK and SCF repository.

1 Like

I'm using Xcode 13.4.1 and it still seems to have this problem, how did you fix it later?

Although SwiftFoundation also requires just-built CoreFoundation, Xcode builds SwiftFoundation successfully.
I wonder why only building TestFoundation fails.