#if DEBUG in Swift

Sigh. The Swift team give an impeccable impression of a group of people who’ve never actually tried to use Swift. An incredibly basic compiler task is to provide code a way to distinguish between debug & release builds, in order that it can behave accordingly (e.g. change the default logging verbosity, change asserts from fatal to… Read more

Stupid Swift error message #a bajillion and one

Input code: Push button.  Expect results (or at least bacon).  Get: Foo.swift:76:21: error: expected ‘,’ separator .day: { String($0 + 1) }, ^ , Foo.swift:76:21: error: expected expression in list of expressions .day: { String($0 + 1) }, ^ Foo.swift:76:21: error: expected ‘,’ separator .day: { String($0 + 1) }, ^ , Believe it or… Read more

Flinging poo in Swift

Thanks to one of the genuine upsides of Swift, full Unicode support in the compiler itself, you can do: Finally you can express yourself honestly within your program: Or, if you prefer to be polite & British about it: You can go further, if you like, and have all manner of interesting things thrown about… Read more

ambiguous reference to member ‘joined()’

"What do you want" scene from The Notebook

You can readily tell that Swift was created by a C++ fanatic, by its fucking obtuse error messages. ⤹ Me             Swift compiler ⤵︎ In today’s episode of “what the fuck do you want, compiler?”, we tackle: foo.swift:186:39: error: ambiguous reference to member ‘joined()’ log.debug(“\(thingies.joined(separator: “, “))”) ^~~~~~~~ Swift.BidirectionalCollection:27:17: note: found this… Read more

Swift’s String.write(toFile:…) can’t handle tildes

Result?  Explode: Error Domain=NSCocoaErrorDomain Code=4 “The folder “sigh.txt” doesn’t exist.” UserInfo={NSFilePath=~/Desktop/sigh.txt, NSUserStringVariant=Folder, NSUnderlyingError=0x1018110b0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}} And since there’s no documentation on that write() method, and this is obviously a perfectly reasonable request that can’t sanely yield that bizarre error message, you could be forgiven for having no idea how… Read more