swift: [SR-543] error: filename "Foo.swift" used twice
Previous ID | SR-543 |
Radar | rdar://problem/34643301 |
Original Reporter | @drewcrawford |
Type | Bug |
Attachment: Download
Environment
swift-2.2-SNAPSHOT-2016-01-11-a
OSX 10.11.2
Additional Detail from JIRA
Votes | 6 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 51e168cfb93f6b87ab9180d9e66125ad
is duplicated by:
- SR-8194 Can’t use the same file name twice
Issue Description:
swift-llbuild has some kind of issue with compiling two sources with the same filename (even with different paths).
Reproduction steps:
1. Open attached project
2. swift build
Or directly with llbuild via
1. Open attached project
2. swift-build-tool -f .build/debug/MultiFilesTest.o/llbuild.yaml
Expected results: compiles
Actual results:
<unknown>:0: error: filename "Foo.swift" used twice: '/Users/drew/Code/MultiFilesTest/MyTarget/Foo.swift' and '/Users/drew/Code/MultiFilesTest/MyTarget/EvenMore/Foo.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: build had 1 command failures
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 17 (6 by maintainers)
Comment by Srđan Rašić (JIRA)
It’s very unfortunate not to be able to use same filenames with different paths. Imagine a very common scenario in iOS development where codebase is grouped by screens. At the moment we are forced to do something like
instead of much cleaner
🙁
That, along with the lack of explicit namespaces often makes code full of unnecessary redundancies. When you add generics, readability of Swift code easily becomes much worse than that of ObjC. Support for more compact type names would help and first step in that direction would be fixing this bug because that would allow us to define classes, like the ones from above example, in extensions which implicitly provide namespaces.
I’m sure that very much people would like to see some improvement here.
Comment by Sergey Suslov (JIRA)
Maybe you can add packages names like in Java? It’s real necessary. For example we have structure like this:
Controller/Cell/Button
AnotherController/Cell/Button
In this case I need to create filename like ControllerCellButton.swift/ AnotherControllerCellButton.swift (and classnames same). It’s real hell.
Comment by sunny (JIRA)
I think it’s quite silly to suggest we should create a framework for each of our MVC combinations. Given that Swift has no support for namespaces, there needs to be a cheap way to repeat filenames or class names. The current situation in Xcode is a lot of filenames like “MasterVie…oller.swift”, especially on my 13" macbook!