Why is it "main.swift", and not "Main.swift"?

As far as I can tell, the naming convention for files and directories in Swift projects is TitleCamelCase. Why, then, is the main entrypoint defined to be “main.swift”, and not “Main.swift”?

You could make a case that the naming convention for files is to name them after the central type defined in the file, and main.swift doesn’t have to define any types. But mostly it was just following the convention of C and Objective-C programs, particularly those created in Xcode, which use “main.c” and “main.m” (respectively).

1 Like

I don’t think Swift per se requires the main file to be called main.swift? You can pass any file to swiftc and it will never complain if the name does not match 'main.swift'

1 Like

Ah, that’s true too, but only if you have just one source file. If you have more than one then you have to use main.swift for the one with top-level code.

is this a package manager thing or a swift thing bc if so it’d be nice if the PM could let you specify the entry point yourself

It’s currently a swiftc thing. I have no objection myself to adding flags to make it customizable, but others might.