Update CLI to use @main
Hi @Kyle-Ye. Thank you for your interest in this project and this quickly proposed pull request!
Multiple pull requests accumulated before we could get back to you here. When looking at all the proposals with overlapping changes, we decided to integrate one which adds availability annotations to unblock developers from using the Swift package on older deployment targets and lets them use availability checks to conditional include functionality. It introduced a conflicting change with this one since the CLI now does a runtime check whether the OS is supported.
My suggestion is to close this PR. Let us know if you disagree.
Thank you!
At first, I was a little curious about what behavior the compiler or runtime would give when the entrance marked by @main had higher target requirements than the current OS.
And the result shows that it may have some bug when @main and @available are used at the same time.
@available(iOS 16.2, macOS 13.1, *)
@main
struct StableDiffusionSample: ParsableCommand {
...
}
For example, I could still run StableDiffusionSample target on iPhone 14 Pro Simulator(iOS 16.1) or even if changing the macOS availability to macOS 13.2, I could still run StableDiffusionSample target on my Mac(macOS 13.1)
Closing the PR due to inactivity. Please feel free to reopen if you think there is an error, thank you! 🙏