Skip to content
Ken Harris edited this page Dec 20, 2017 · 5 revisions

Swift has an #if system for conditional compilation, but there's no #error, so there's no obvious way to halt compilation. Easy workaround: import a library that doesn't exist.

#if os(macOS)
    import AppKit
#elseif os(iOS)
    import UIKit
#else
    import CompileTimeErrorPlease
#endif
Clone this wiki locally