We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MacOS 10.12.3 Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) Target: x86_64-apple-macosx10.9 Xcode: Version 8.2.1 (8C1002)
Tested and Verified on Ubuntu 16.04 too: Swift version 3.0.2 (swift-3.0.2-RELEASE) Target: x86_64-unknown-linux-gnu
md5: 4b56fd7b3b6a10be28430c3b9f7314e2
Issue Description:
It is not possible to have any subdirectories under the Sources/ directory. Creating subdirectories gives the following error:
Sources/
error: the package has an unsupported layout, unexpected source file(s) found: /Users/petar/Downloads/SwiftPackageTest/Sources/main.swift fix: move the file(s) inside a module
One should be able to organize code using subdirectories. Not being able to do so will make the folder structure hard to maintain over time.
See example demonstrating this below:
()==[:::::::::::::> ~/Downloads/SwiftPackageTest @ Petar-MBP (petar) $swift package init --type executable Creating executable package: SwiftPackageTest Creating Package.swift Creating .gitignore Creating Sources/ Creating Sources/main.swift Creating Tests/ ()==[:::::::::::::> ~/Downloads/SwiftPackageTest @ Petar-MBP (petar) $swift build Compile Swift Module 'SwiftPackageTest' (1 sources) Linking ./.build/debug/SwiftPackageTest ()==[:::::::::::::> ~/Downloads/SwiftPackageTest @ Petar-MBP (petar) $./.build/debug/SwiftPackageTest Hello, world! ()==[:::::::::::::> ~/Downloads/SwiftPackageTest @ Petar-MBP (petar) $mkdir Sources/folder_to_organize_code ()==[:::::::::::::> ~/Downloads/SwiftPackageTest @ Petar-MBP (petar) $swift build error: the package has an unsupported layout, unexpected source file(s) found: /Users/petar/Downloads/SwiftPackageTest/Sources/main.swift fix: move the file(s) inside a module ()==[:::::::::::::> ~/Downloads/SwiftPackageTest @ Petar-MBP (petar)
The text was updated successfully, but these errors were encountered:
Directories under Sources/ acts as Swift modules. The rules for layouts is here: https://github.com/apple/swift-package-manager/blob/master/Documentation/Reference.md#module-format-reference
You can arrange your sources inside a module's directory when using multiple module layout, something like this:
One module layout example (this has one executable module) . ├── Package.swift └── Sources └── main.swift Multiple module layout example (this has two modules one executable and one library. The exe module has a subdir models.) . ├── Package.swift └── Sources ├── exe │ ├── main.swift │ └── models │ └── hello.swift └── module2 └── foo.swift
Sorry, something went wrong.
Comment by Petar (JIRA)
Thank you! I tried looking for this but failed to find any information.
No branches or pull requests
Environment
MacOS 10.12.3
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Xcode: Version 8.2.1 (8C1002)
Tested and Verified on Ubuntu 16.04 too:
Swift version 3.0.2 (swift-3.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
md5: 4b56fd7b3b6a10be28430c3b9f7314e2
Issue Description:
It is not possible to have any subdirectories under the
Sources/
directory. Creating subdirectories gives the following error:One should be able to organize code using subdirectories. Not being able to do so will make the folder structure hard to maintain over time.
See example demonstrating this below:
The text was updated successfully, but these errors were encountered: