rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
822 stars 87 forks source link

Xcode 12.4 Missing return in a closure expected to return 'AnyView' #78

Open ekordin opened 1 year ago

ekordin commented 1 year ago

In Xcode 12.4, Stinsen v2.0.9: Adding the library by CocoaPods or by SPM, but compilation failed in the NavigationViewCoordinator.swift

Any ideas except updating the macOS? (I can fix the Stinsen's code locally, but it will not work for the rest of the team)

public class NavigationViewCoordinator<T: Coordinatable>: ViewWrapperCoordinator<T, AnyView> {
    public init(_ childCoordinator: T) {
        super.init(childCoordinator) { view in
            #if os(macOS)
            AnyView(
                NavigationView {
                    view
                }
            )
            #else
            AnyView( // Missing return in a closure expected to return 'AnyView' ; did you mean to return the last expression?
                NavigationView {
                    view
                }
                .navigationViewStyle(StackNavigationViewStyle())
            )
            #endif
        }
    }

    @available(*, unavailable)
    public override init(_ childCoordinator: T, _ view: @escaping (AnyView) -> AnyView) {
        fatalError("view cannot be customized")
    }
}
LePips commented 1 year ago

This is implicit return in Swift 5.1. You either must be using that version or later, which you should be able to do with Xcode 12.4, or update your Xcode version.

ekordin commented 1 year ago

This is implicit return in Swift 5.1. You either must be using that version or later, which you should be able to do with Xcode 12.4, or update your Xcode version.

I understand this, but I didn't want to modify the Stinsen code locally and fetch the code via pods.

LePips commented 1 year ago

Updating your Swift version does not require modification of Stinsen.