UICollectionReusableView - Missing return in a function
assert()
is evaluated only in the Debug configuration. When you buildan archive then the code is compiled in the Release configuration(with optimizations) and the condition is simply ignored (assumedto be true
). Therefore the compiler complains about the missingreturn value.
You can use
fatalError("Unexpected element kind")
instead. fatalError()
is always evaluated and in addition markedwith @noreturn
(resp. return type Never
in Swift 3) so that the compiler knows that it does not return to its caller.