🥺 Hard to debug/develop SwiftFoundation

Once upon a time, we were able to develop SwiftFoundation only with Xcode, latest toolchain, swift-corelibs-xctest repo, and swift-corelibs-foundation repo.
Nowadays, we can't do so because:

  • SR-12177 hinders our using latest toolchain to run TestFoundation.

  • Xcode's default toolchain lacks some(all?) SPIs and can't compile SwiftFoundation. (For example, "Cannot find '_forEachField' in scope" errors occur because @_spi(Reflection) import Swift imports no SPI symbols.)

  • TestFoundation can't be compiled with any toolchain using Xcode which tries to load duplicately modulemaps of CoreFoundation. [Forum topic #50360] [GitHub issue #4608]

Thus we must checkout swift repo and related repos and run 'swift/utils/build-script' to test SwiftFoundation.
How do we regain the past condition?
I have no idea.


I haven't had the chance to try it myself yet, but do you think the improvements in Swift 5.7 for module aliasing could help with the CoreFoundation import issue?

For the _forEachField thing, I think the ultimate resolution is to find a way to get reflection to be a first class Swift feature. AttributedString needs to use it to get the API surface we wanted, unfortunately.

1 Like

IIUC, CoreFoundation is a simple clang module that is not supported by SE-0339, isn't it?

  • Only pure Swift modules allowed for aliasing: no ObjC/C/C++/Asm due to potential symbol collision.

I agree.
However, as mentioned above, the overlay also requires @_spi feature, so that the problem is more general.

I've been trying to debug SwiftFoundation recently and have run into the same problem.
I'm trying other ways to debug SwiftFoundation,actually not ideal.
Can you tell me more about "Thus we must checkout swift repo and related repos and run 'swift/utils/build-script' to test SwiftFoundation."?

Sorry, but I think I should have added "on Linux" to that sentence... :speak_no_evil:
'build-script' seems not to build TestFoundation on macOS.

I'm disappointed that it looks like the problem of not being able to compile with Xcode has been around for a long time,And I don't see any official Apple developers providing us with answers or working on solutions.