Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

compnerd
Copy link
Contributor

@compnerd compnerd commented Aug 4, 2023

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.

@compnerd compnerd force-pushed the swift branch 3 times, most recently from 9b6c99c to 51e693e Compare August 5, 2023 16:16
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;
Copy link
Contributor

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

Copy link
Contributor Author

@compnerd compnerd Sep 5, 2023

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.

Copy link
Contributor

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.

@github-actions github-actions bot added the tests: in-progress This PR's integration tests are in progress. label Oct 20, 2023
@github-actions
Copy link

github-actions bot commented Oct 20, 2023

✅  Integration test succeeded!

Requested by @jonsimantov on commit refs/pull/1414/merge
Last updated: Wed Mar 13 16:30 PDT 2024
View integration test log & download artifacts

@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Oct 20, 2023
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Oct 20, 2023
@github-actions github-actions bot added tests: succeeded This PR's integration tests succeeded. and removed tests: failed This PR's integration tests failed. labels Oct 20, 2023
@jonsimantov jonsimantov self-requested a review October 23, 2023 17:34
jonsimantov
jonsimantov previously approved these changes Oct 23, 2023
Copy link
Contributor

@jonsimantov jonsimantov left a 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).

@jonsimantov jonsimantov added the skip-release-notes Skip release notes check label Oct 23, 2023
@github-actions github-actions bot dismissed jonsimantov’s stale review October 23, 2023 17:51

🍞 Dismissed stale approval on external PR.

@jonsimantov jonsimantov self-requested a review October 23, 2023 18:03
jonsimantov
jonsimantov previously approved these changes Oct 23, 2023
@compnerd
Copy link
Contributor Author

@jonsimantov - anything else left before we can merge this?

@github-actions github-actions bot dismissed jonsimantov’s stale review January 16, 2024 22:53

🍞 Dismissed stale approval on external PR.

@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: failed This PR's integration tests failed. and removed tests: succeeded This PR's integration tests succeeded. labels Jan 16, 2024
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jan 17, 2024
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests: failed This PR's integration tests failed. labels Jan 31, 2024
@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Jan 31, 2024
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Jan 31, 2024
@github-actions github-actions bot added tests: succeeded This PR's integration tests succeeded. and removed tests: failed This PR's integration tests failed. labels Feb 1, 2024
@jonsimantov jonsimantov self-requested a review February 1, 2024 18:23
jonsimantov
jonsimantov previously approved these changes Feb 1, 2024
Copy link
Contributor

@jonsimantov jonsimantov left a 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.

@github-actions github-actions bot dismissed jonsimantov’s stale review March 13, 2024 21:33

🍞 Dismissed stale approval on external PR.

@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. tests: succeeded This PR's integration tests succeeded. and removed tests: succeeded This PR's integration tests succeeded. labels Mar 13, 2024
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Mar 13, 2024
@wti
Copy link

wti commented Aug 22, 2024

bumping (with apologies) in case this can be merged, so people can use it...

@jonsimantov
Copy link
Contributor

You should have permission to merge since I approved it, but if not, let me know and I'll do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-release-notes Skip release notes check tests: succeeded This PR's integration tests succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants