1

I have created a class named Bundle, which I'd really like to remain named that way, as it perfectly describes what it's for in my project.
Now, I'm using Swift's Bundle in some code and now those names are conflicting. I had this issue before when I created the class Set. I was able to solve that by putting Swift.Set when I wanted to use the standard Set class, as I found in this answer on exactly this matter.
I also tried to apply that solution my Bundle problem, but Xcode complains:

Module 'Swift' has no member named 'Bundle'

Any idea why it does work for Set, but not Bundle?
Thanks!

LinusGeffarth
  • 27,197
  • 29
  • 120
  • 174
  • 1
    I would *really* consider renaming *your* class ... – Martin R Dec 04 '17 at 14:42
  • I'm always trying to improve my coding style. Why would you *really* suggest renaming it? – LinusGeffarth Dec 04 '17 at 14:44
  • Just my (spontaneous, personal) opinion. Avoiding the name collision seems less confusing to me in the long run. What if a new developer works on your project, and does not know that there are different Bundle classes? – Martin R Dec 04 '17 at 14:48
  • That certainly is an argument. However, 1) the error will let him know and 2) I'm trying really hard to document well, so that anyone can get started working on it, without any prior knowledge of my project. – LinusGeffarth Dec 04 '17 at 14:50

1 Answers1

4

Bundle is defined in the Foundation library, not in the Swift standard library:

let mainBundle = Foundation.Bundle.main
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382