Cannot convert value of type 🍎 iOS

Swift: Cannot convert value of type 'X' to expected argument type 'Y'

The value’s type doesn’t match what the function or property expects.

Seen on: iOS

Meaning

Common with optionals (String? vs String), numeric types (Int vs Double/CGFloat), closures with wrong signatures, and Binding vs value in SwiftUI.

Common causes

  • Optional passed where a non-optional is needed
  • Different numeric types without conversion
  • Closure signature mismatch
  • Passing a value instead of a Binding ($state)

⚡ Quick fix

  1. Unwrap optionals (if let/guard/??)
  2. Convert explicitly: Double(x), CGFloat(y)
  3. Use $ for bindings in SwiftUI

Detailed fix by platform

Swift

  1. swift
    let width: CGFloat = CGFloat(columns) * 44
    Toggle("Notifications", isOn: $settings.enabled)

How to diagnose

  1. Types — Actual vs expected
  2. Context — Optional/numeric/binding?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.