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.
Cannot convert value of typeto expected argument typeCannot convert value of type 'String?' to expected argument type 'String' 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
- Unwrap optionals (if let/guard/??)
- Convert explicitly: Double(x), CGFloat(y)
- Use $ for bindings in SwiftUI
Detailed fix by platform
Swift
- swift
let width: CGFloat = CGFloat(columns) * 44 Toggle("Notifications", isOn: $settings.enabled)
How to diagnose
- Types — Actual vs expected
- 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:
Similar errors
Most viewed in iOS
- SIGABRT Thread 1: signal SIGABRT (app crashes with "libc++abi: terminating")
- ITMS-91053 ITMS-91053: Missing API declaration — Your app's code references required reason APIs (privacy manifest)
- dyld: Library not loaded dyld: Library not loaded: @rpath/X.framework/X — Reason: image not found (crash on launch)
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026