-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed compilation on Mac Catalyst #306
base: main
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
3 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Sources/AsyncHTTPClient/NIOTransportServices/TLSConfiguration.swift
Outdated
Show resolved
Hide resolved
Sources/AsyncHTTPClient/NIOTransportServices/TLSConfiguration.swift
Outdated
Show resolved
Hide resolved
note that /**
* @enum SSLProtocol enumeration
* @abstract Enumerations for the set of supported TLS and DTLS protocol versions.
*
* @note This enumeration is deprecated. Use `tls_protocol_version_t` instead.
*/
public enum SSLProtocol : Int32 {
@available(iOS, introduced: 5.0, deprecated: 13.0)
@available(macCatalyst, introduced: 13.0, deprecated: 13.0)
// ...
} |
CC @Lukasa |
Hmm, given your notes above I went back and checked: I have no trouble building the package for macCatalyst. The fact that the macCatalyst guards are redundant suggests that you shouldn't be either. Are you confident that your Xcode build is using the Xcode toolchain and not an OSS one? |
I'm increasingly wondering if some of the platform checking for |
For now we can address the warning about |
How do you build it? I have only Xcode installed, OSS Swift running typically in Docker; The problem came up after importing AHC as Swift package to another iOS Xcode project (supporting macCatalyst platform). |
I've been building directly by opening the Package.swift in Xcode using Xcode 12 beta. |
This is when opening async-http-client directly, not when using it as a dependency? |
yes |
Hmm, let me get hold of a machine that matches your setup and I'll try to replicate it. |
Thank you, please let me know if/what to check/change on my end. |
Ok, I have validated this definitely occurs. I'm going to reach out to some colleagues to see if I can understand this better. So far as I know the macCatalyst availability is strictly the same as the iOS availability, so I think this is just a bug in Xcode. |
Ok, after some chatting with my colleagues this appears to be due to the awkward combination of the following: I propose we change the block to this:
This code is pretty hideous, but it avoids the concern I have about that block scaling up to being too big. We can do the same in the other block. Want to update to that? |
@Lukasa thank you for following up on that, updated PR as suggested, let me know if you have more comments BTW when compiling for Mac Catalyst there is still warning:
Not sure if it makes sense to try to fix it (for example by putting the availability inside of targetEnvironment condition), |
Yeah, I'm aware of it: I've reported it as a bug upstream. For now I think we have to tolerate it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, LGTM. Thanks!
@swift-server-bot test this please |
Just some minor formatting issues to cleanup there. |
@swift-server-bot test this please |
1 similar comment
@swift-server-bot test this please |
Aaand now we bump into SR-11560. |
There are probably no good routes out of this. Linux doesn't believe macCatalyst exists, so any reference to it will warn, but we have to refer to it in order to get a safe macCatalyst build because it has an explicit unavailable marker for the nonexistent macCatalyst 12-and-earlier version. |
how to define one way to solve this would be to drop support for iOS12. that way AHC would support 2 stable iOS versions and Mac Catalyst |
Ok, after some digging I've come up with a proposal. If we wrap the Does that sound acceptable to you @pokryfka? |
Thank you for following on that.
To be honest supporting only iOS14/Sift5.3 is not ideal but an improvement nevertheless.
I am not sure I understood it correctly, just tried (ugly!): if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) {
sec_protocol_options_set_min_tls_protocol_version(options.securityProtocolOptions, self.minimumTLSVersion.nwTLSProtocolVersion)
} else {
#if swift(>=5.3)
#if !targetEnvironment(macCatalyst)
sec_protocol_options_set_tls_min_version(options.securityProtocolOptions, self.minimumTLSVersion.sslProtocol)
#else
preconditionFailure("macCatalyst 13 is the first version of macCatalyst")
#endif
#endif
} but it still fails on Linux with Swift 5.2:
|
Try |
#if compiler(>=5.3)
#if !targetEnvironment(macCatalyst)
sec_protocol_options_set_tls_min_version(options.securityProtocolOptions, self.minimumTLSVersion.sslProtocol)
#else
preconditionFailure("macCatalyst 13 is the first version of macCatalyst")
#endif
#endif Same, does not compile on Linux and Swift5.2 tested using the docker compose file in the repo:
|
@swift-server-bot test this please |
@@ -67,15 +68,23 @@ | |||
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) { | |||
sec_protocol_options_set_min_tls_protocol_version(options.securityProtocolOptions, self.minimumTLSVersion.nwTLSProtocolVersion) | |||
} else { | |||
sec_protocol_options_set_tls_min_version(options.securityProtocolOptions, self.minimumTLSVersion.sslProtocol) | |||
#if !targetEnvironment(macCatalyst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pokryfka you'll need to do
#if compiler(>=5.3)
#if !targetEnvironment(macCatalyst)
sec_protocol_options_set_tls_min_version(options.securityProtocolOptions, self.minimumTLSVersion.sslProtocol)
#else
preconditionFailure("macCatalyst 13 is the first version of macCatalyst")
#endif
#else
sec_protocol_options_set_tls_min_version(options.securityProtocolOptions, self.minimumTLSVersion.sslProtocol)
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
friendly ping @pokryfka
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the reminder and previous comment
my (personal) project using Catalyst and AHC, and in fact swift-server in general, is waiting for my professional contract to finish, which is in a few weeks 🎉
anyway, its a small change, and would be great to be able to use official AHC in my project
will test it and update the PR tomorrow
@weissi actually, I did not push the change back then but I did try
|
@swift-server-bot test this please |
1 similar comment
@swift-server-bot test this please |
Fix compilation on macCatalyst platform.
Motivation:
Support compilation on macCatalyst platform.
Modifications:
Updated availability guards in
TLSConfiguration
.Result:
Fixes compilation on macCatalyst platform.
Closes #304