# Is \`module.modulemap\` required for C/Objc targets?

**URL:** <https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332>\
**Category:** Package Manager\
**Tags:** module\
**Created:** [July 16, 2026, 12:57pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332 "2026-07-16T12:57:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frizlab](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/frizlab/32/416_2.png) [@Frizlab](https://forums.swift.org/u/Frizlab)\
**Post date:** [July 16, 2026, 12:57pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332/1 "2026-07-16T12:57:47Z")

</div>

I have [an issue](https://github.com/swiftlang/swift/issues/90687) with `swift run --repl` when using Swift 6.4 beta (`swift-driver version: 1.168.4 Apple Swift version 6.4 (swiftlang-6.4.0.25.4 clang-2100.3.25.1) – Target: arm64-apple-macosx27.0.0`).

The problem happens when running the command in a package that has a target (or that has a dependency which has a target) which is not written in Swift (tested with C, ObjC), and that does not have a `module.modulemap` file in the `include` folder.

The package compiles fine when using `swift build`, but when using the REPL we get a “missing module” error, for the modules that are not written in Swift.  
Adding the `module.modulemap` fixes the issue (ignoring _another_ issue, where the REPL is launched using standalone `-I` options (with no value) randomly in the command-line, which hides actual, useful `-I` options, but that’s another problem…)

My question is: Is the `module.modulemap` file technically required?  
If it is, it’s the build step that is at fault, and it should fail. If not, the REPL run should generate the `module.modulemap` file(s) and add them in the search path for Swift’s invocation.

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [July 16, 2026, 1:08pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332/2 "2026-07-16T13:08:12Z")

</div>

Yes, module maps are required—Swift only understands C headers at the module level, not the individual header level.

I would expect SwiftPM using `swift run --repl` to pass the required flags to the REPL invocation the same way it passes them to the compiler when doing a regular build. If that doesn't work, it sounds like a SwiftPM bug (so your issue is probably better filed under swift-package-manager instead of swift, but I'll let the owners of that project make that determination).

---

<div class="post-metadata">

**Author:** ![Frizlab](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/frizlab/32/416_2.png) [@Frizlab](https://forums.swift.org/u/Frizlab)\
**Post date:** [July 16, 2026, 1:44pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332/3 "2026-07-16T13:44:48Z")

</div>

Thanks!  
That’s true even if I have made an umbrella header in the `include` folder, right?

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [July 16, 2026, 1:47pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332/4 "2026-07-16T13:47:03Z")

</div>

I should clarify, the module map is required _by the compiler_. SwiftPM, sitting on top of the compiler, will automatically generate a module map for you if you have headers in your `include` folder if you don't supply one yourself. So the compiler does require it (the directory it's in must be passed via `-I`), but SwiftPM adds the extra convenience on top.

---

<div class="post-metadata">

**Author:** ![Frizlab](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/frizlab/32/416_2.png) [@Frizlab](https://forums.swift.org/u/Frizlab)\
**Post date:** [July 16, 2026, 1:48pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332/5 "2026-07-16T13:48:30Z")

</div>

Oh so that looks definitely like an SPM bug, specifically for the `run --repl` command. I’ll move my issue there.

---

<div class="post-metadata">

**Author:** ![Frizlab](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/frizlab/32/416_2.png) [@Frizlab](https://forums.swift.org/u/Frizlab)\
**Post date:** [July 16, 2026, 8:01pm UTC](https://forums.swift.org/t/is-module-modulemap-required-for-c-objc-targets/88332/6 "2026-07-16T20:01:06Z")

</div>

Done

> <https://github.com/swiftlang/swift-package-manager/issues/10307>
>
> \### Is it reproducible with SwiftPM command-line tools: \`swift build\`, \`swift te…st\`, \`swift package\` etc?
> 
> \- \[x\] Confirmed reproduction steps with SwiftPM CLI. The description text \_must\_ include reproduction steps with either of command-line SwiftPM commands, \`swift build\`, \`swift test\`, \`swift package\` etc.
> 
> \### Description
> 
> This is a re-write of https://github.com/swiftlang/swift/issues/90687, because I’ve been told the package manager is a better location for the bug.
> 
> Setup:
> A package that has a target (e.g. \`Dest\`) depending on non-Swift target(s) (e.g. \`Dep1\` and \`Dep2\`, tested with C, ObjC), and whose target(s) do not contain a \`module.modulemap\`.
> 
> Issue:
> Running \`swift run --repl\` gives a REPL in which \`Dest\` cannot be imported (we get a “missing required module” error, for the modules \`Dep1\` and \`Dep2\`, other dependencies work fine).
> 
> \### Expected behavior
> 
> The import should work.
> 
> \### Actual behavior
> 
> We get the error \`missing required modules: 'CMacroExports', 'CNSTaskHelptender'\`.
> 
> \### Steps to reproduce
> 
> 1. git clone https://github.com/xcode-actions/swift-process-invocation.git
> 2. cd swift-process-invocation
> 3. swift run --repl
> 4. Once in the REPL (if you can get there; there is another issue I’ll open that can prevent getting there, but relaunching should do the trick), try to \`import ProcessInvocation\`.
> 
> \### Swift Package Manager version/commit hash
> 
> Swift Package Manager - Swift 6.4.0-dev (Xcode 27.0 beta 3 (27A5218g))
> 
> \### Swift & OS version (output of \`swift --version ; uname -a\`)
> 
> swift-driver version: 1.168.4 Apple Swift version 6.4 (swiftlang-6.4.0.25.4 clang-2100.3.25.1)
> Target: arm64-apple-macosx27.0.0
> Darwin Frizlabs-MacBook-Pro-Beta-Mojo.local 27.0.0 Darwin Kernel Version 27.0.0: Mon Jun 29 21:26:19 PDT 2026; root:xnu-13432.0.50.501.3~1/RELEASE\_ARM64\_T6031 arm64
