-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add a couple of workarounds for Swift on Windows #1414
base: main
Are you sure you want to change the base?
Conversation
9b6c99c
to
51e693e
Compare
The C++ Interop efforts in Swift currently have some limitations. In particular, it cannot support trivial types with non-trivial destructors. As a workaround, provide a copy constructor which can be used by the Swift interop while using the regular semantics for all other cases. A second issue arises in the handling of futures. Unfortunately, it is not currently possible to pass an indirect block parameter which prevents the construction of a callback. Workaround this by providing an inline shim to use a direct parameter (i.e. indirect value through a pointer) which then allows a callback to be formed. Both of these items are being tracked upstream but seem to be potentially sufficient to enable the use of Swift for using the C++ SDK for desktop scenarios.
#if FIREBASE_PLATFORM_WINDOWS | ||
namespace firebase { | ||
namespace auth { | ||
Auth::Auth(const Auth &) noexcept = default; |
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.
I'm uncomfortable having this copy constructor broadly available for all Windows developers. Could you wrap this and all of the other changes in an #if for the Swift compatibility that you can use in your build? e.g. FIREBASE_SWIFT_WINDOWS=1
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.
That wouldn't work. That would mean that the distribution of firebase would not be usable as the copy-constructor would not be available when used for Swift.
Note that the header actually indicates that the copy constructor is not declared (and thus the compiler will synthesize one - except because it is a movable type, it will prefer to move it) when the interop is not enabled. This means that this is only going to add the distribution size but will be discarded by the linker as static linking is employed. As a result the copy constructor is not available for Windows developers, they would need to define __swift__
for it to be made available.
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.
OK, I'm following. I'll take another look at this after our next release goes out.
✅ Integration test succeeded!Requested by @jonsimantov on commit refs/pull/1414/merge |
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.
This looks good to merge, though we will need to confirm after merge that it doesn't break our C++ packaging tests and Unity SDK build (in which case we'd need to roll it back).
🍞 Dismissed stale approval on external PR.
@jonsimantov - anything else left before we can merge this? |
🍞 Dismissed stale approval on external PR.
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.
Looks good - let's go ahead and get this in. I do want to make sure this doesn't cause any weirdness with our public release, but I'll take a look next time we do one and roll this back if it needs any changes at that point.
🍞 Dismissed stale approval on external PR.
bumping (with apologies) in case this can be merged, so people can use it... |
You should have permission to merge since I approved it, but if not, let me know and I'll do it. |
The C++ Interop efforts in Swift currently have some limitations. In particular, it cannot support trivial types with non-trivial destructors. As a workaround, provide a copy constructor which can be used by the Swift interop while using the regular semantics for all other cases.
A second issue arises in the handling of futures. Unfortunately, it is not currently possible to pass an indirect block parameter which prevents the construction of a callback. Workaround this by providing an inline shim to use a direct parameter (i.e. indirect value through a pointer) which then allows a callback to be formed.
Both of these items are being tracked upstream but seem to be potentially sufficient to enable the use of Swift for using the C++ SDK for desktop scenarios.