Missing return in a function expected to return iOS Origin: On your device OSI layer 7 · Application Last updated 25 Nov 2026

error: Missing return in a function expected to return 'Int'

A code path in your function ends without returning a value.

Exact message you may see Missing return in a function expected to returnMissing return in closure expected to returnerror: missing return in instance method expected to return 'Int'
Seen on: iOS Swift

Meaning

Every branch must return or throw. Add a final return, handle else/default, or return inside the switch cases.

Common causes

  • if without else return
  • Switch missing a case
  • Early exit forgot to return

⚡ Quick fix

  1. Add a return in every branch
  2. Add default: in the switch
  3. Use fatalError only for impossible paths

Detailed fix by platform

Swift

  1. func level(_ x: Int) -> String { switch x { case 0: return "low"; default: return "high" } }

How to diagnose

  1. Branch — returns?
  2. Switch — exhaustive?
  3. Early exits — ok?

🔧 Still not fixed?

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

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

'init' is inaccessible due to 'private' protection level — error: 'init' is inaccessible due to 'internal' protection level (iOS)'init' is inaccessibl…'nil' requires a contextual type / Cannot infer type — error: 'nil' requires a contextual type (iOS)'nil' requires a cont…Ambiguous use of 'init' / trailing closure — error: ambiguous use of 'init(content:)' (iOS)Ambiguous use of 'ini…Argument of '#selector' refers to instance method that is not exposed to Objective-C — error: argument of '#selector' refers to instance method 'tap()' that is not exposed to Objective-C (iOS)Argument of '#selecto…Cannot find 'x' in scope — error: Cannot find 'viewModel' in scope (iOS)Cannot find 'x' in sc…Cannot use instance member as a default parameter — error: cannot use instance member 'x' as a default parameter (iOS)Cannot use instance m…Missing argument for parameter / Extra argument in call — error: Missing argument for parameter 'id' in call (iOS)Missing argument for …Result of call is unused (warning) — warning: result of call to 'foo()' is unused (iOS)Result of call is unu…Missing r…

Explore the map of this error Full error map →

🧠 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.