<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi,</div><div><br></div><div>Isn't it odd to have both main.swift and Main.swift for a project?</div><div><br></div><div>Considering Swift 3 provides source breaking changes, can this be still worth an side effort to pursue with the compiler team as advised by Kostiantyn in the bug report? <span style="background-color: rgba(255, 255, 255, 0);">If so, how'd I approach them regarding this?</span></div><div><br></div><div>Isn't the Swift Package Manager a (new) tool in handling Swift code? Is this really the case where a minor change/addition to a convention is so difficult that it shouldn't be done? Can't Xcode support only either Main.swift or main.swift in the future?</div><div><br></div><div>The bug report is linked here</div><div><a href="https://bugs.swift.org/browse/SR-1379">https://bugs.swift.org/browse/SR-1379</a></div><div><br></div><div><div></div>On May 2, 2016, at 09:34, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">[+swift-dev, bcc swift-users] I’d be fine with supporting “Main.swift”. The one downside is that it could change behavior for existing projects relying on “Main.swift” being a library file, and that might mean it’s not worth making a change.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On May 1, 2016, at 23:34, Kostiantyn Koval via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi there,</div><div class=""><br class=""></div><div class=""><b class="">main </b>is common used naming for executables that contains main function. It’s required by Swift compiler and Swift Package Manager can’t do anything about that.</div><div class="">If you create a simple command line tool in Xcode, it will create <b class="">main.swift</b> file. If you try to rename it, it will feil.</div><div class="">I think this is correct behaviour.</div><div class="">If you still think that Swift should support <b class="">Main.swift </b>with upper case letter, than it should be discussed with compiler team.</div><div class=""><br class=""></div><div class="">- Kostiantyn</div><div class=""><br class=""></div>
> Hi there,<br class="">> <br class="">> This is what happened as I was trying out the Swift Package Manager for another project similar to the one shown below:<br class="">> <br class="">> ~ $ mkdir example<br class="">> ~ $ cd example/<br class="">> example $ touch Package.swift<br class="">> example $ mkdir Sources<br class="">> <br class="">> example $ vi Sources/Example.swift<br class="">> example $ cat Sources/Example.swift<br class="">> func printOther() {<br class="">> print("other")<br class="">> }<br class="">> <br class="">> example $ vi Sources/Main.swift<br class="">> example $ cat Sources/Main.swift<br class="">> print("Hello World")<br class="">> printOther()<br class="">> <br class="">> <br class="">> example $ swift build<br class="">> Compile Swift Module 'example' (2 sources)<br class="">> /PATH/example/Sources/Main.swift:1:1: error: expressions are not allowed at the top level<br class="">> print("Hello World")<br class="">> ^<br class="">> /PATH/example/Sources/Main.swift:2:1: error: expressions are not allowed at the top level<br class="">> printOther()<br class="">> ^<br class="">> /PATH/example/Sources/Main.swift:1:1: error: expressions are not allowed at the top level<br class="">> print("Hello World")<br class="">> ^<br class="">> /PATH/example/Sources/Main.swift:2:1: error: expressions are not allowed at the top level<br class="">> printOther()<br class="">> ^<br class="">> <unknown>:0: error: build had 1 command failures<br class="">> error: exit(1): /PATH-SWIFT/usr/bin/swift-build-tool -f /PATH/example/.build/debug.yaml<br class="">> <br class="">> <br class="">> example $ mv Sources/Main.swift Sources/main.swift<br class="">> example $ swift build<br class="">> Compile Swift Module 'example' (2 sources)<br class="">> Linking .build/debug/example<br class="">> example $ .build/debug/example<br class="">> Hello World<br class="">> other<br class="">> example $<br class="">> <br class="">> <br class="">> I had to renameMain.swifttomain.swift. Is there a design decision on why the filename for the main swift file has to be lowercase or is this a bug?<br class="">> <br class="">> If it’s a design decision, why are directory names forsource files allowed to have variations likeSources,Source,srcandsrcsas statedhere(<a href="https://github.com/apple/swift-package-manager/blob/master/Documentation/SourceLayouts.md#other-rules" class="">https://github.com/apple/swift-package-manager/blob/master/Documentation/SourceLayouts.md#other-rules</a>)but not the main swift file?<br class="">> <br class="">> I’d be ok if onlyMain.swiftandmain.swiftare allowed since other files in theSourcesdirectory are commonly UpperCamelCasedue to the Type naming conventions e.g.example-package-playingcard/Sources(<a href="https://github.com/apple/example-package-playingcard/tree/master/Sources" class="">https://github.com/apple/example-package-playingcard/tree/master/Sources</a>).<br class="">> <br class="">> Or maybe I’m just being pedantic?<br class="">> <br class="">> p.s. evenPackage.swiftis capitalized and notpackage.swift<br class="">> <br class="">> $ swift --version<br class="">> Swift version 3.0-dev (LLVM 752e1430fc, Clang 1e6cba3ce3, Swift 56052cfe61)<br class="">> Target: x86_64-unknown-linux-gnu<br class="">> <br class="">> <br class="">> <br class="">> <br class="">><span class="Apple-converted-space"> </span>
</div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></blockquote></body></html>