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

Fixed iOS push module compilation issue on some versions of XCode #373

Merged
merged 6 commits into from
Apr 26, 2022

Conversation

ikurek
Copy link
Contributor

@ikurek ikurek commented Apr 19, 2022

This should solve #347. Apparently, for some combinations of Swift/XCode versions the compiler doesn't correctly recognize the let guard statements, which leads to handle and channelName being identified as nullable types, although they are guarded by specific checks before they are used. I've made a non-nullable, unwrapped versions of those variables to avoid those compilation errors.

@ikurek ikurek added the bug Something isn't working. It's clear that this does need to be fixed. label Apr 19, 2022
@ikurek ikurek requested a review from QuintinWillison April 19, 2022 14:22
@ikurek ikurek self-assigned this Apr 19, 2022
@github-actions github-actions bot temporarily deployed to staging/pull/373/dartdoc April 19, 2022 14:24 Inactive
@lawrence-forooghian
Copy link
Collaborator

lawrence-forooghian commented Apr 20, 2022

I think it might be worth us trying to reproduce #347, so we can have more confidence in our fix. The guard let foo = foo syntax isn't new in Swift - it's been around for quite a while. Furthermore, somebody else has reported it happening in Xcode 13.2, which is very new.

Can we try to get further information from the issue creators? Perhaps they could supply us with some sample code to reproduce the issue.

@ikurek
Copy link
Contributor Author

ikurek commented Apr 21, 2022

I think it might be worth us trying to reproduce #347, so we can have more confidence in our fix. The guard let foo = foo syntax isn't new in Swift - it's been around for quite a while. Furthermore, somebody else has reported it happening in Xcode 13.2, which is very new.

I'm aware that the guard let used here is a pretty standard structure for Swift code, but judging from the stacktrace that users provided, It's highly probable that it causes the compilation issue.

Can we try to get further information from the issue creators? Perhaps they could supply us with some sample code to reproduce the issue.

I'm not very familiar with iOS development environment, but the issue seems to be device-specific and I failed to reproduce it on my machines, with XCode 12 and 13 😞 Since this is a compile-time problem, I don't think users will be able to support us with sample code - the problem lies within the Ably library, and users don't modify it on their side.

Copy link
Contributor

@QuintinWillison QuintinWillison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have sympathy for @lawrence-forooghian's suggestion, however I'm also keen for us to get this fix in front of the user that reported it, as well as other users potentially.

Do we have any idea if there may be other areas of this codebase at risk of this particular Swift compiler issue?

Also, I think it would be really helpful for you to add some commentary to the code where you use the either nullable prefix (as I suggest) or your Unwrapped suffix to explain exactly why this 'dance' is being done.

ios/Classes/handlers/PushHandlers.swift Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to staging/pull/373/dartdoc April 21, 2022 15:55 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/373/dartdoc April 21, 2022 16:26 Inactive
@ikurek ikurek requested a review from QuintinWillison April 21, 2022 16:29
@github-actions github-actions bot temporarily deployed to staging/pull/373/dartdoc April 21, 2022 16:31 Inactive
@ikurek
Copy link
Contributor Author

ikurek commented Apr 21, 2022

The introduced fixes seem to solve the problem, confirmed by one of affected users here: #347 (comment)

@github-actions github-actions bot temporarily deployed to staging/pull/373/dartdoc April 21, 2022 16:40 Inactive
@ikurek
Copy link
Contributor Author

ikurek commented Apr 21, 2022

I have sympathy for @lawrence-forooghian's suggestion, however I'm also keen for us to get this fix in front of the user that reported it, as well as other users potentially.

This seems to be an edge case for specific versions of development tools. I managed to get the issue only in a few specific configurations of XCode / MacOS / Flutter versions and it seems to be some sort of compiler issue. I think the fix should be enough to solve the case.

Do we have any idea if there may be other areas of this codebase at risk of this particular Swift compiler issue?

There isn't too much Swift code in the repository, it's mostly Objective C. I've checked and the problematic guard let foo = foo structure isn't widely used in the codebase, so there should be no further issues with this

Also, I think it would be really helpful for you to add some commentary to the code where you use the either nullable prefix (as I suggest) or your Unwrapped suffix to explain exactly why this 'dance' is being done.

I've left a comment with a short explanation and link to the issue in cf7b9cb

Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to approve if @QuintinWillison is keen to get this merged as-is 👍

@ikurek ikurek merged commit bb680fe into main Apr 26, 2022
@ikurek ikurek deleted the fix/ios-push-channel-compilation-error branch April 26, 2022 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

Successfully merging this pull request may close these issues.

3 participants