             return (val as! NSNumber).doubleValue
         }
 
-        var ret: Attribute!
-
-        // Bug in Swift prevents us from putting directives inside switch statements (https://bugs.swift.org/browse/SR-2)
-
-        #if os(watchOS)
-        #else
-            switch name {
+        let ret: Attribute
+
+        switch name {
+        #if !os(watchOS)
             case .attachment: ret = .attachment(validate(foundationValue))
             case .shadow: ret = .shadow(validate(foundationValue))
-            default: break
-            }
-        #endif
-
-        #if os(macOS)
-            switch name {
+        #endif
+        #if os(macOS)
             case .cursor: ret = .cursor(validate(foundationValue))
             case .markedClauseSegment: ret = .markedClauseSegment(validate(foundationValue))
             case .spellingState: ret = .spellingState(SpellingState(rawValue: validate(foundationValue))!)
             case .superscript: ret = .superscript(validate(foundationValue))
             case .textAlternatives: ret = .textAlternatives(validate(foundationValue))
             case .toolTip: ret = .toolTip(validate(foundationValue))
-            default: break
-            }
-        #endif
-
-        switch name {
+        #endif
         case .baselineOffset: ret = .baselineOffset(validateDouble(foundationValue))
         case .backgroundColor: ret = .backgroundColor(validate(foundationValue))
         case .expansion: ret = .expansion(validateDouble(foundationValue))

            let values: [Int] = validate(foundationValue)
            ret = .writingDirections(values.compactMap(WritingDirection.init))
        default:
            if ret == nil {
                ret = .custom(name.rawValue, foundationValue)
            }
        }

        self = ret

        case .verticalGlyphForm(let form): return form
        case .writingDirections(let directions): return directions
        case .custom(_, let value): return value
        }
    }

    /// The value that is passed into the original attribute dictionary of Foundation's API for NSAttributedStrings. Consists of basic types such as Int, Color, Font, etc.
    public var foundationValue: Any {
        switch self {
        #if os(macOS)
            case .spellingState(let state): return state.rawValue
        #endif
        case .ligatures(let ligatures): return ligatures.rawValue
        case .strikethroughStyle(let style): return style.rawValue
        case .textEffect(let effect): return effect.rawValue
