I have the following swift code executing in playground:
func A() { print ("Hello") guard 1 == 2 else { return } defer {
Put the defer block before the scope is exited:
defer
func A() { print ("Hello") defer { print ("World") } guard 1 == 2 else { return } } A()