It’s not clear what your goal is here. My best guess is that you’re looking to report a bug. If so, I recommend that you do this officially by opening an issue.
Please post the bug link, just for the record.
If I’ve misunderstood this, please elaborate on what help you’re looking for.
FWIW, outside of Apple's UI frameworks, I wouldn't recommend to use localizedDescription at all. It gives you very bad error messages (always prints ErrorType error code 1 (and it's always code 1)) and is only contained in the legacy bits of Foundation anyway. If you import the modern import FoundationEssentials you won't see localizedDescription at all. You can just avoid the .localizedDescription, type fewer characters and get better error messages.
Example:
import FoundationEssentials
public class BotError: Error {}
print(BotError())
Of course, your program should still work of course so it's still a valid bug report.
my goal was to report a bug and the bug tag in this topic is proof of that. I didn't know where to report errors correctly and didn't create it in the compiler repository because the compilation of this code was error-free. Thanks for your help
thanks for the advice, I was very cautious about FoundationEssentials as I am developing on macbook and macOS doesn't have FoundationEssentials and I was afraid of any differences that might affect the execution logic of the application. Please confirm that it is ready for production, I will then use it on a permanent basis.
I understand correctly that I will have to use something like this construct:
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
Is this a normal practice in my case ? Just it seems a little bit inconvenient to use
Yes, that's currently the best practise. I agree that it's not nice but that's where we are and happens to be the way you get the best cross-platform compatibility between Apple OSes and the others.
The code in FoundationEssentials is OSS and almost completely shared between Darwin and non-Darwin (but is only reachable via import Foundation on Darwin ). The code that's in Foundation but not FoundationEssentials on non-Darwin platforms is OSS but part of the legacy swift-corelibs-foundation project and is not shared with Darwin (which has its own proprietary implementation for those APIs).