Getting "guard body may not fall through" error when setting up Google Analytics on iOS Project (in Swift) [duplicate] Getting "guard body may not fall through" error when setting up Google Analytics on iOS Project (in Swift) [duplicate] swift swift

Getting "guard body may not fall through" error when setting up Google Analytics on iOS Project (in Swift) [duplicate]


guard let function needs to exit the current scope of your gai variable. So you need to modify your code to

guard let gai = GAI.sharedInstance() else {    assert(false, "Google Analytics not configured correctly")    return true//Base on your function return type, it may be returning something else}

Here is the document:

The else clause of a guard statement is required, and must either call a function marked with the noreturn attribute or transfer program control outside the guard statement’s enclosing scope using one of the following statements:

return break continue throw