You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ swift --version
Swift version 3.0-dev (LLVM 752e1430fc, Clang 1e6cba3ce3, Swift 56052cfe61)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
Votes
0
Component/s
Compiler, Package Manager
Labels
Bug
Assignee
None
Priority
Medium
md5: b3b8d38188bf24995cd29d03a4f52b43
Issue Description:
Hi there,
I was advised to post this as a bug report. This was originally an email out to the Swift Users mailing list.
This is what happened as I was trying out the Swift Package Manager for another project similar to the one shown below:
~ $ mkdir example
~ $ cd example/
example $ touch Package.swift
example $ mkdir Sources
example $ vi Sources/Example.swift
example $ cat Sources/Example.swift
func printOther() {
print("other")
}
example $ vi Sources/Main.swift
example $ cat Sources/Main.swift
print("Hello World")
printOther()
example $ swift build
Compile Swift Module 'example' (2 sources)
/PATH/example/Sources/Main.swift:1:1: error: expressions are not allowed at the top level
print("Hello World")
^
/PATH/example/Sources/Main.swift:2:1: error: expressions are not allowed at the top level
printOther()
^
/PATH/example/Sources/Main.swift:1:1: error: expressions are not allowed at the top level
print("Hello World")
^
/PATH/example/Sources/Main.swift:2:1: error: expressions are not allowed at the top level
printOther()
^
<unknown>:0: error: build had 1 command failures
error: exit(1): /PATH-SWIFT/usr/bin/swift-build-tool -f /PATH/example/.build/debug.yaml
example $ mv Sources/Main.swift Sources/main.swift
example $ swift build
Compile Swift Module 'example' (2 sources)
Linking .build/debug/example
example $ .build/debug/example
Hello World
other
example $
I had to rename Main.swift to main.swift. Is there a design decision on why the filename for the main swift file has to be lowercase or is this a bug?
If it's a design decision, why are directory names for source files allowed to have variations like Sources, Source, src and srcs as stated here but not the main swift file?
I'd be ok if only Main.swift and main.swift are allowed since other files in the Sources directory are commonly UpperCamelCase due to the Type naming conventions e.g. example-package-playingcard/Sources.
Or maybe I'm just being pedantic?
p.s. even Package.swift is capitalized and not package.swift
The text was updated successfully, but these errors were encountered:
I think `main.` file with lowercase letter is a standard and it's commonly used in many languages. I think we should be consistent and keep `main.swift` and not `Main.swift`
P.S
If I make a new project in Xcode, it creates main.swift file too.
I think we should consider rejecting Main.swift as a source file name. Even if we think it should be spelled main.swift, that makes having a non-main Main.swift is confusing at best.
I suggest SwiftPM considers Main.swift and main.swift the same thing. Or rather use Main.swift instead of main.swift. I think naming consistency inside Swift ecosystem makes much more sense than consistency with other languages.
Attachment: Download
Environment
Additional Detail from JIRA
md5: b3b8d38188bf24995cd29d03a4f52b43
Issue Description:
Hi there,
I was advised to post this as a bug report. This was originally an email out to the Swift Users mailing list.
This is what happened as I was trying out the Swift Package Manager for another project similar to the one shown below:
I had to rename
Main.swift
tomain.swift
. Is there a design decision on why the filename for the main swift file has to be lowercase or is this a bug?If it's a design decision, why are directory names for source files allowed to have variations like
Sources
,Source
,src
andsrcs
as stated here but not the main swift file?I'd be ok if only
Main.swift
andmain.swift
are allowed since other files in the Sources directory are commonly UpperCamelCase due to the Type naming conventions e.g. example-package-playingcard/Sources.Or maybe I'm just being pedantic?
p.s. even
Package.swift
is capitalized and notpackage.swift
The text was updated successfully, but these errors were encountered: