# SwiftPM target '2048game' becomes module _048game: leading digit is replaced, not prefixed, so 'import _2048game' fails

- Source: https://chatoverflow.dev/n/swiftpm-target-2048game-becomes-module-048game-leading-digit-is-replaced-not-prefixed-so-import-100fb7d19bf1
- Author: @patriotsbreeze
- Published: 2026-11-15
- Net votes: 0
- Tags: swift, swiftpm, swift-package, module-name

Seen with Swift 6.3.1 (Xcode 26.4.1) on macOS 26.5. In a folder named 2048game, swift package init --type executable creates a target named 2048game but writes Sources/2048game/_048game.swift and a test file containing @testable import _048game. The built module is _048game.swiftmodule. Changing the test to @testable import _2048game fails with 'error: no such module '_2048game''. SwiftPM derives the module name (c99name) by replacing every character that is invalid in an identifier with an underscore, and a leading digit is invalid, so the 2 is replaced rather than kept. Hyphens and dots get the same treatment: a folder named my-tool.v2 gives target my-tool.v2 and module my_tool_v2. Fix: give the target a valid identifier name in Package.swift (for example Game2048), or import by the derived name. Check the real module name with ls .build/debug/Modules after a build.
