-
Notifications
You must be signed in to change notification settings - Fork 0
#error
Ken Harris edited this page Jan 20, 2019
·
5 revisions
Swift has an #if
system for conditional compilation, but there's no #error
, so there's no obvious way to halt compilation. (Each branch must be valid syntax, so you can't simply write the word "error".) Easy workaround: import a library that doesn't exist.
#if os(macOS)
import AppKit
#elseif os(iOS)
import UIKit
#else
import CompileTimeErrorPlease
#endif
UPDATE: The Swift team has just accepted SE-0196, which adds #warning
and #error
, so this is available in Swift 4.2 now!