Error during build in ChatBoxApp.swift
Hello! I came across your project and decided to try and build it. I am running into an error in ChatBotApp.swift,
Missing argument for parameter #1 in call
and
Closure containing control flow statement cannot be used with result builder 'SceneBuilder'
The errors are being thrown in the block of code.
.conditionally {
if #available(macOS 13.0, *) {
$0.defaultSize(width: 1000, height: 800)
}
}
Any ideas? I'd love to check out your app if I can get it to build.
Thanks!
same issue, it compiles correctly if you comment that out though. Only issue is you won't have a predefined width and height of the window on launch, but at least it works.
I also stumbled upon this issue but managed to find an alternative solution that keeps the default size. Applying the following patch, the application compiles and works as expected:
diff --git a/ChatBot/ChatBotApp.swift b/ChatBot/ChatBotApp.swift
index c2e2cb1..44c5c0a 100644
--- a/ChatBot/ChatBotApp.swift
+++ b/ChatBot/ChatBotApp.swift
@@ -53,9 +53,15 @@ struct ChatBotApp: App {
}
}
.conditionally {
- if #available(macOS 13.0, *) {
- $0.defaultSize(width: 1000, height: 800)
- }
+ setDefaultSize($0)
+ }
+ }
+
+ private func setDefaultSize(_ scene: some Scene) -> some Scene {
+ if #available(macOS 13.0, *) {
+ return scene.defaultSize(width: 1000, height: 800)
+ } else {
+ return scene
}
}
}
I am not sure if there is a more elegant way to achieve the same outcome. If you want to test this patch and previously launched the application, remember to remove the container (i.e., ~/Library/Containers/ChatBot) first as .defaultSize only affects the first launch.
Ooops, seems like I forgot to push my local changes to Github. I'm sorry for that. I'm pushing it now.
The problem is if #available statement is now available on Xcode 14.4 beta. This is a new feature for SceneBuilder. I just use it for convenience but forgot this version of Xcode is still in beta. So sorry for that.
I also stumbled upon this issue but managed to find an alternative solution that keeps the default size. Applying the following patch, the application compiles and works as expected:
diff --git a/ChatBot/ChatBotApp.swift b/ChatBot/ChatBotApp.swift index c2e2cb1..44c5c0a 100644 --- a/ChatBot/ChatBotApp.swift +++ b/ChatBot/ChatBotApp.swift @@ -53,9 +53,15 @@ struct ChatBotApp: App { } } .conditionally { - if #available(macOS 13.0, *) { - $0.defaultSize(width: 1000, height: 800) - } + setDefaultSize($0) + } + } + + private func setDefaultSize(_ scene: some Scene) -> some Scene { + if #available(macOS 13.0, *) { + return scene.defaultSize(width: 1000, height: 800) + } else { + return scene } } }I am not sure if there is a more elegant way to achieve the same outcome. If you want to test this patch and previously launched the application, remember to remove the container (i.e.,
~/Library/Containers/ChatBot) first as.defaultSizeonly affects the first launch.
This is a good way. But finally, I remove the default size.
@solid-pixel @dnlfrst @gorbypark Fixed. Please update your clone and try it again. If the issue is gone, please close the issue. Thanks. And sorry again for my mistake.🥹
@LiYanan2004 you have nothing to apologize for you've done a tremendous job with this app, thanks a lot!
@solid-pixel Thanks
The fix works as expected, @LiYanan2004 feel free to close the issue. This is only possible as a contributor/maintainer, so you have to do this. 😉