Missing toolchain modules on macOS?

when running swift symbolgraph-extract on linux, i get the following modules by default:

$ swift symbolgraph-extract -module-name x -target x86_64-unknown-linux-gnu -output-dir ~/test
Couldn't load module 'x' in the current SDK and search paths.
Current visible modules:
CDispatch
CFURLSessionInterface
CFXMLInterface
CoreFoundation
Cxx
CxxStdlib
Dispatch
DispatchIntrospection
Distributed
Foundation
FoundationNetworking
FoundationXML
Glibc
Observation
RegexBuilder
Swift
SwiftBridging
SwiftGlibc
SwiftOnoneSupport
SwiftOverlayShims
SwiftShims
XCTest
_Backtracing
_Builtin_intrinsics
_Builtin_stddef_max_align_t
_Concurrency
_Differentiation
_InternalStaticMirror
_InternalSwiftScan
_RegexParser
_StringProcessing
_SwiftConcurrencyShims

on macOS, some of these seem to be missing.

  1. _RegexParser
  2. _Differentiation
  3. XCTest
  4. FoundationNetworking
  5. FoundationXML

iā€™m aware that the Foundation modules are supposed to be different due to macOS adopting the swift-foundation project, but i am surprised that _RegexParser, _Differentiation, and XCTest are also missing. is this expected?

1 Like

Foundation is provided by the OS on macOS so it is not currently built as part of the toolchain build. _RegexParser is an implementation module used by the compiler and the string processing module, so I'm not surprised that it's stripped from the final toolchain build. _Differentiation is still a very experimental module that's not meant for public consumption (yet?), and XCTest is provided by the OS on macOS as well.

is it possible to emit their symbolgraphs on macOS, or are they unavailable?

XCTest is the only one that's really relevant here, because it's the only one that's a public module available on macOS. _Differentiation is experimental and not shipped with Xcode toolchains, _RegexParser is a private implementation detail as Alejandro mentioned (clients should not use it), and Foundation(Networking|XML) are Linux-only splits; Foundation on macOS isn't structured that way.

XCTest is distributed as a developer framework in Xcode, so in addition to providing the SDK search path, you also need to add the platform's developer frameworks path to the swift invocation. This works for me:

xcrun swift symbolgraph-extract -module-name XCTest \
  -target arm64-apple-macos14.2 -output-dir . \
  -sdk $(xcrun --sdk macosx --show-sdk-path) \
  -F $(xcrun --sdk macosx --show-sdk-platform-path)/Developer/Library/Frameworks
3 Likes