Am having this challenge, flutter app on Xcode. The challenge is when I run build am seeing this error nil is not compatible with type Any in coercion

nil is shorthand for Optional<X>.none. Since you’re casting directly to Any with no context, the compiler can’t determine what X is. You’ll have to provide some context which you can do with something like (nil as X?) as Any

When I put x? In the code I only saw just one error Cannot fine X in the

After I wrote x? In the code I got one error then after the same error came back…

It's usually easier to fix the code when a minimal self-contained example is provided. And it will also help you debug the issue yourself.

I think you most likely wanted to add parentheses to the ternary operator so it reads (size != 0 ? size : nil) as Any.

Here are a few examples of what works and what is not:

let size: Int = 4
let dict1: [String: Any] = ["size": size != 0 ? size : nil] // warning: Expression implicitly coerced from 'Int?' to 'Any'
let dict2: [String: Any] = ["size": (size != 0 ? size : nil) as Any] // ok
let dict3: [String: Any] = ["size": size != 0 ? size : nil as Any] // error: 'nil' is not compatible with type 'Any' in coercion
let dict4: [String: Any] = ["size": size != 0 ? size as Any : Optional<Int>.none as Any] // ok, but unnecessarily explicit

@ksemianov it worked, thank you and when I run build I got another error Property timeSensitiveSetting not found on object of type UNNotificationSetting

@jjatie thank you too