PC パソコン

How to Fix “Missing Argument for Parameter in Call” in Swift

When calling a Swift function or initializer, Xcode may report an error such as:

Missing argument for parameter 'age' in call

or:

Missing argument for parameter 'completion' in call

This error means that the selected function or initializer requires a parameter for which the call site does not provide a corresponding argument.

Common causes include changing a function signature without updating callers, adding a stored property to a struct, omitting a parameter that has no default value, using incorrect argument labels or ordering, forgetting to pass a SwiftUI Binding, or failing to provide a required closure.

The most reliable fix is to inspect the current function or initializer signature and make sure the call supplies every required argument with the correct label, order, and type.

  1. What does “Missing argument for parameter in call” mean?
  2. The basic fix
  3. The reported missing parameter may not be the only problem
  4. Typical situations where the error appears
  5. Common causes
    1. 1. A required argument is simply missing
    2. 2. An initializer argument is missing
    3. 3. A function gained a new parameter
    4. 4. A new stored property changed initialization requirements
    5. 5. A non-default parameter was omitted
    6. 6. A parameter no longer has a default value
    7. 7. An argument label is incorrect
    8. 8. A parameter has no external label
    9. 9. The argument order is wrong
    10. 10. A SwiftUI custom view gained a new property
    11. 11. A SwiftUI @Binding argument was not supplied
    12. 12. A custom initializer requires more arguments
    13. 13. A required trailing closure is missing
    14. 14. A required action closure is omitted
    15. 15. One of multiple closure arguments is missing
    16. 16. The wrong overload is being considered
    17. 17. Optional mismatches interfere with overload resolution
    18. 18. Binding and plain values are confused
    19. 19. An SDK or package changed its API
    20. 20. An earlier argument is the real cause
  6. What to check first
    1. 1. Read the parameter name in the error
    2. 2. Open the function or initializer declaration
    3. 3. Use Xcode autocomplete and Quick Help
    4. 4. Check the earliest compiler error
  7. Solution 1: Supply the missing argument
  8. Solution 2: Remove a parameter that is not actually needed
  9. Solution 3: Add a default argument
  10. Solution 4: Supply all required initializer arguments
  11. Solution 5: Give a stored property a default value when appropriate
  12. Solution 6: Add a default to a custom initializer
  13. Solution 7: Use the correct argument labels
  14. Solution 8: Supply unlabeled parameters correctly
  15. Solution 9: Match the declared parameter order
  16. Solution 10: Update every call after changing a function signature
  17. Solution 11: Pass every required SwiftUI view value
  18. Solution 12: Pass a Binding to @Binding properties
  19. Solution 13: Do not hide a required Binding with an arbitrary default
  20. Solution 14: Provide a required trailing closure
  21. Solution 15: Pass the closure as a labeled argument
  22. Solution 16: Supply all multiple trailing closures
  23. Solution 17: Add a closure default only when omission is meaningful
  24. Solution 18: Unwrap optionals so the intended overload can match
  25. Solution 19: Correct argument types
  26. Solution 20: Inspect overload candidates
  27. Solution 21: Review memberwise initializers after adding a custom init
  28. Solution 22: Check access control
  29. Solution 23: Check the current SDK or package signature after updates
  30. Solution 24: Rebuild the call with Xcode autocomplete
  31. Solution 25: Break complex calls into typed intermediate values
  32. Solution 26: Inspect arguments before the reported problem
  33. Solution 27: Use the correct TextField initializer in SwiftUI
  34. Solution 28: Supply the required Button action
  35. Solution 29: Verify generic SwiftUI initializers such as NavigationLink
  36. Solution 30: Consider redesigning APIs with many required arguments
  37. If the error occurs in SwiftUI
  38. If the error occurs with a struct memberwise initializer
  39. If the error occurs in a function call
  40. If the error occurs in an initializer
  41. If you believe the argument is already present
  42. When should you use a default argument?
  43. Will Clean Build Folder or deleting DerivedData fix it?
  44. What you should avoid
  45. Fast troubleshooting checklist
  46. Summary

What does “Missing argument for parameter in call” mean?

Consider:

func createUser( name: String, age: Int ) { print("\(name): \(age)") }

The function requires two parameters: name and age.

This call provides only one:

createUser( name: "Alice" )

Swift therefore reports:

Missing argument for parameter 'age' in call

The basic fix

Supply the missing argument:

createUser( name: "Alice", age: 20 )

The reported missing parameter may not be the only problem

Suppose the declaration is:

func update( _ value: Int, animated: Bool ) { }

but the call is:

update( value: 10 )

The first argument label is also wrong, and animated is missing.

Always compare the entire call with the declaration instead of fixing only the parameter named in one diagnostic.

Important: A missing-argument error can be secondary to an earlier label, type, optional, binding, or overload mismatch.

Typical situations where the error appears

  • A required function argument was omitted
  • An initializer argument was omitted
  • A new parameter was added to a function
  • A new stored property changed a struct initializer
  • A custom initializer was changed
  • A parameter without a default value was omitted
  • An argument label is incorrect
  • Arguments are in the wrong order
  • A SwiftUI custom view is missing a required property value
  • A required Binding was not passed
  • A required trailing closure was omitted
  • One of several closure arguments is missing
  • An SDK or package update changed the signature
  • Older sample code no longer matches the current API

Common causes

1. A required argument is simply missing

func login( email: String, password: String ) { }

login(
email: "alice@example.com"
)

The password argument is missing.

2. An initializer argument is missing

struct User { let name: String let age: Int }

let user = User(
name: "Alice"
)

If the available memberwise initializer requires both properties, age must also be supplied.

3. A function gained a new parameter

Old declaration:

func save( name: String ) { }

New declaration:

func save( name: String, overwrite: Bool ) { }

An old call now lacks overwrite.

4. A new stored property changed initialization requirements

Before:

struct Product { let name: String }

After:

struct Product { let name: String let price: Int }

Existing memberwise initializer calls may now need price.

5. A non-default parameter was omitted

func show( title: String, animated: Bool ) { }

show(
title: "Settings"
)

6. A parameter no longer has a default value

This version allows omission:

func show( title: String, animated: Bool = true ) { }

This version does not:

func show( title: String, animated: Bool ) { }

7. An argument label is incorrect

func move( from start: Int, to end: Int ) { }

move(
from: 1,
to: 10
)

The external labels are from and to, not start and end.

8. A parameter has no external label

func multiply( _ value: Int, by multiplier: Int ) -> Int { value * multiplier }

let result = multiply(
5,
by: 3
)

9. The argument order is wrong

func register( name: String, email: String, age: Int ) { }

The call should follow the declared parameter order.

10. A SwiftUI custom view gained a new property

struct ProfileView: View { let name: String let age: Int
var body: some View {
    Text(name)
}

}

An older call that provides only name may no longer compile.

11. A SwiftUI @Binding argument was not supplied

struct EditView: View { @Binding var name: String
var body: some View {
    TextField(
        "Name",
        text: $name
    )
}

}

The caller must provide a Binding<String>.

12. A custom initializer requires more arguments

struct UserView: View { let name: String let age: Int
init(
    name: String,
    age: Int
) {
    self.name = name
    self.age = age
}

var body: some View {
    Text(name)
}

}

13. A required trailing closure is missing

func load( completion: (String) -> Void ) { }

load()

The completion argument is required.

14. A required action closure is omitted

func perform( action: () -> Void ) { }

15. One of multiple closure arguments is missing

func request( success: () -> Void, failure: (Error) -> Void ) { }

Supplying success alone is not enough.

16. The wrong overload is being considered

A type mismatch elsewhere in the call may eliminate the intended overload and leave another candidate that requires additional parameters.

17. Optional mismatches interfere with overload resolution

Passing User? to an API that expects User can trigger a chain of diagnostics, including a missing-argument error on another candidate.

18. Binding and plain values are confused

In SwiftUI, passing a String where a Binding<String> is expected may prevent the intended initializer from matching.

19. An SDK or package changed its API

A newer version may introduce a required parameter or reorganize an initializer.

20. An earlier argument is the real cause

A wrong argument label or type may cause Swift to select or diagnose the wrong candidate.

What to check first

1. Read the parameter name in the error

If Xcode reports:

Missing argument for parameter 'age' in call

the candidate Swift is considering requires an age parameter.

2. Open the function or initializer declaration

If the declaration is:

init( name: String, age: Int )

both arguments are required unless a default is provided.

3. Use Xcode autocomplete and Quick Help

Retype the function or initializer name and inspect the signatures that are actually available in the SDK or package version your project uses.

4. Check the earliest compiler error

A missing-argument diagnostic may be secondary.

Tip: In SwiftUI and heavily generic code, fix concrete type, binding, or label errors first. The missing-argument message may disappear automatically.

Solution 1: Supply the missing argument

func createUser( name: String, age: Int ) { }

createUser(
name: "Alice",
age: 20
)

Solution 2: Remove a parameter that is not actually needed

func createUser( name: String ) { print(name) }

createUser(
name: "Alice"
)

If a parameter no longer serves a purpose, simplifying the API may be better than forcing every caller to supply a meaningless value.

Solution 3: Add a default argument

func show( title: String, animated: Bool = true ) { }

show(
title: "Settings"
)

Warning: Add defaults only when omission has a clear and correct meaning. Do not use arbitrary defaults merely to silence the compiler.

Solution 4: Supply all required initializer arguments

struct User { let name: String let age: Int }

let user = User(
name: "Alice",
age: 20
)

Solution 5: Give a stored property a default value when appropriate

struct User { var name: String var age: Int = 0 }

let user = User(
name: "Alice"
)

Actual synthesized initializer availability also depends on access control and custom initializer declarations, so check the candidates Xcode offers.

Solution 6: Add a default to a custom initializer

struct User { let name: String let age: Int
init(
    name: String,
    age: Int = 0
) {
    self.name = name
    self.age = age
}

}

let user = User(
name: "Alice"
)

Solution 7: Use the correct argument labels

func move( from start: Int, to end: Int ) { }

move(
from: 1,
to: 10
)

Solution 8: Supply unlabeled parameters correctly

func setValue( _ value: Int, animated: Bool ) { }

setValue(
10,
animated: true
)

Solution 9: Match the declared parameter order

func register( name: String, email: String, age: Int ) { }

register(
name: "Alice",
email: "alice@example.com",
age: 20
)

Solution 10: Update every call after changing a function signature

func save( name: String, overwrite: Bool ) { }

save(
name: "data.json",
overwrite: false
)

Use Xcode refactoring features when possible to reduce stale call sites.

Solution 11: Pass every required SwiftUI view value

struct ProfileView: View { let name: String let age: Int
var body: some View {
    Text("\(name) \(age)")
}

}

ProfileView(
name: "Alice",
age: 20
)

Solution 12: Pass a Binding to @Binding properties

struct EditView: View { @Binding var name: String
var body: some View {
    TextField(
        "Name",
        text: $name
    )
}

}

struct ContentView: View {
@State private var name = ""

var body: some View {
    EditView(
        name: $name
    )
}

}

Solution 13: Do not hide a required Binding with an arbitrary default

If a child view is supposed to edit state owned elsewhere, supply the actual Binding.

If the state truly belongs to the child, redesign the property as locally owned state instead of pretending the binding is optional.

Solution 14: Provide a required trailing closure

func load( completion: (String) -> Void ) { }

load { value in
print(value)
}

Solution 15: Pass the closure as a labeled argument

load( completion: { value in print(value) } )

Solution 16: Supply all multiple trailing closures

func request( success: () -> Void, failure: (Error) -> Void ) { }

request {
print("Success")
} failure: { error in
print(error)
}

Solution 17: Add a closure default only when omission is meaningful

func request( success: () -> Void, failure: (Error) -> Void = { _ in } ) { }

Be careful: silently ignoring errors may not be appropriate for your application.

Solution 18: Unwrap optionals so the intended overload can match

func show( user: User, animated: Bool ) { }

if let user {
show(
user: user,
animated: true
)
}

Solution 19: Correct argument types

func show( title: String, count: Int ) { }

show(
title: "Items",
count: 10
)

A type mismatch earlier in the call can eliminate the intended candidate and produce a misleading missing-argument diagnostic.

Solution 20: Inspect overload candidates

func open( id: Int ) { }

func open(
name: String,
animated: Bool
) {
}

open(
name: "Settings",
animated: true
)

Make sure the argument types and labels select the overload you intended.

Solution 21: Review memberwise initializers after adding a custom init

If the initializer you expected is no longer available, declare it explicitly:

struct User { let name: String let age: Int
init(
    name: String,
    age: Int
) {
    self.name = name
    self.age = age
}

}

Solution 22: Check access control

Across modules, an initializer may not be visible unless it has the appropriate access level:

public init( name: String, age: Int ) { self.name = name self.age = age }

Solution 23: Check the current SDK or package signature after updates

If an old sample calls:

SomeAPI( value: value )

but the current API requires:

SomeAPI( value: value, configuration: configuration )

the call must be updated.

Use current Xcode declaration information and current package documentation rather than relying on an older code sample.

Solution 24: Rebuild the call with Xcode autocomplete

Retyping the function or initializer name lets Xcode show the currently available argument labels and parameter structure.

This is particularly useful after API changes or refactoring.

Solution 25: Break complex calls into typed intermediate values

let userValue: User = user let titleValue: String = title let settingsValue: Settings = settings

CustomView(
user: userValue,
title: titleValue,
settings: settingsValue,
action: action
)

This separates argument-type failures from missing-parameter failures.

Solution 26: Inspect arguments before the reported problem

If you have:

SomeView( title: count, enabled: true )

and title expects String, fix that mismatch first:

SomeView( title: String(count), enabled: true )

The later missing-argument diagnostic may then disappear.

Solution 27: Use the correct TextField initializer in SwiftUI

@State private var text = ""

TextField(
"Name",
text: $text
)

A missing or incorrect Binding can cause Swift to consider a different initializer and report confusing follow-up diagnostics.

Solution 28: Supply the required Button action

Button("Save") { save() }

or:

Button { save() } label: { Text("Save") }

Make sure the initializer has all required action and label closures.

Solution 29: Verify generic SwiftUI initializers such as NavigationLink

NavigationLink, Picker, and other generic SwiftUI APIs may produce missing-argument errors when the real problem is a mismatched value type, destination type, Binding, or label closure.

Check the entire initializer rather than only the named missing parameter.

Solution 30: Consider redesigning APIs with many required arguments

If a function is repeatedly breaking because it has many parameters, group related values into a configuration model:

struct UserConfiguration { let name: String let age: Int let enabled: Bool }

func createUser(
configuration: UserConfiguration
) {
}

let configuration = UserConfiguration(
name: "Alice",
age: 20,
enabled: true
)

createUser(
configuration: configuration
)

This can make large APIs easier to evolve.

If the error occurs in SwiftUI

Check these items in order:

  1. Inspect the custom view’s current stored properties.
  2. Check whether it defines a custom initializer.
  3. Look for newly added @Binding properties.
  4. Pass every required value from the call site.
  5. Use $property when a Binding is required.
  6. Verify argument labels and order.
  7. Check optional versus non-optional types.
  8. Fix earlier compiler errors first.

If the error occurs with a struct memberwise initializer

struct Product { let name: String let price: Int }

let product = Product(
name: "Book",
price: 1000
)

If price should be optional at the call site, use an appropriate stored-property default or custom initializer rather than simply omitting a required value.

If the error occurs in a function call

func upload( file: Data, completion: (Result<Void, Error>) -> Void ) { }

upload(
file: data
) { result in
switch result {
case .success:
print("Completed")

case .failure(let error):
    print(error)
}

}

The trailing closure satisfies the completion parameter.

If the error occurs in an initializer

For:

init( title: String, count: Int )

call:

SomeType( title: "Items", count: 10 )

If you believe the argument is already present

Check for:

  • An incorrect argument label
  • Wrong parameter ordering
  • A wrong argument type
  • Optional versus non-optional mismatch
  • Binding versus plain value mismatch
  • A different overload being selected
  • A custom initializer changing available signatures
  • A same-named type from another module
  • An SDK or package version change

When should you use a default argument?

A default is useful when omission has a clear meaning:

func show( title: String, animated: Bool = true ) { }

Here, animated naturally defaults to true.

Do not give arbitrary defaults to values such as required IDs, authentication credentials, or other data whose absence should be treated as an error.

Will Clean Build Folder or deleting DerivedData fix it?

Usually not.

This diagnostic normally reflects a mismatch between the source call and an available function or initializer signature.

Cleaning:

Product → Clean Build Folder

or deleting DerivedData:

rm -rf ~/Library/Developer/Xcode/DerivedData/*

does not add a missing argument to your code.

Note: Check the declaration and call site before treating this as a build-cache problem.

What you should avoid

Do not supply arbitrary values such as 0, false, an empty string, or nil merely to make the compiler error disappear.

For example, passing age: 0 may compile but still be invalid application data.

Determine why the parameter exists. Supply the correct value if it is required, or redesign the API with a meaningful default if omission is legitimate.

Fast troubleshooting checklist

  1. Read the missing parameter name from the error.
  2. Open the function or initializer declaration.
  3. Confirm every required parameter is present.
  4. Check argument labels.
  5. Check argument order.
  6. Check argument types.
  7. Check for default arguments.
  8. Review recent function signature changes.
  9. Check recently added struct properties.
  10. Check custom initializers.
  11. In SwiftUI, inspect @Binding properties.
  12. Check whether a trailing closure is required.
  13. Inspect overload candidates.
  14. Check whether an SDK or package update changed the signature.
  15. Fix earlier concrete compiler errors first.

Summary

Swift’s “Missing argument for parameter in call” error means that the function or initializer selected by the compiler requires a parameter for which the call site supplies no corresponding argument.

Common causes include omitted arguments, changed function signatures, newly added struct properties, custom initializers, missing defaults, SwiftUI bindings, required closures, and API version changes.

Start by opening the current function or initializer declaration and compare its parameter count, labels, order, and types with the call site.

Supply the correct value when the parameter is genuinely required. If omission is a valid use case, consider a meaningful default argument or a simpler API design.

In SwiftUI, pay special attention to newly added properties, @Binding values, optional types, and generic initializer selection. Also fix earlier type or label errors first, because a missing-argument message can sometimes be only a secondary diagnostic.