False error. "module name "foo" is not a valid identifier"
Originator: | AlexanderMomchilov | ||
Number: | rdar://FB9726200 | Date Originated: | 27 October, 2021 |
Status: | Open | Resolved: | |
Product: | Xcode | Product Version: | Xcode Version 13.1 (13A1030d) |
Classification: | Incorrect/Unexpected Behavior | Reproducible: |
I have a tiny demo project that builds just fine (I’ve attached it). It has two Swift files that aren’t a member of any target. If either one is checked off to be added to the `DemoPrivilegedHelper` target, the build fails with a seemingly completely unrelated error: ``` error: module name "ca.momchilov.Demo-Privileged-Helper-App.helper" is not a valid identifier Command CompileSwiftSources failed with a nonzero exit code ``` ### Please list the steps you took to reproduce the issue: 1. Open the attached sample project. 2. Build it, and confirm that it builds just fine. 3. Select either `PrivilegedHelperConstants.swift` or `PrivilegedHelperConstants.swift`, and check off their target membership checkbox to add them to the `DemoPrivilegedHelper` ### What did you expect to happen? For the project to build like normal ### What actually happened? `swiftc` errors out with this message: ``` error: module name "ca.momchilov.Demo-Privileged-Helper-App.helper" is not a valid identifier Command CompileSwiftSources failed with a nonzero exit code ```
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Root cause found
In a Swift project with only one
main.swift
file, Xcode disregards the providedPRODUCT_MODULE_NAME
in the Xcode project settings and uses-module-name main
.Swift Forums link
This is discussed on the forums, here: https://forums.swift.org/t/is-this-a-swiftc-bug-error-module-name-foo-is-not-a-valid-identifier/53119