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

AvailabilityParser marks iOSApplicationExtension, unavailable-annotated properties as universally deprecated #450

Closed
1 of 2 tasks
davidme-stripe opened this issue Jan 4, 2023 · 4 comments · Fixed by #712
Assignees
Labels
bug Something isn't working

Comments

@davidme-stripe
Copy link

davidme-stripe commented Jan 4, 2023

Description

When generating our SDK docs with DocC, classes marked as unavailable in Application Extensions are marked as deprecated in the generated docs.

CleanShot 2023-01-04 at 15 08 43@2x

Steps To Reproduce

Generated DocC page for PaymentSheet.FlowController
Class definition for PaymentSheet.FlowController

If we define our class:

@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
public class MyClass: NSObject { }

The Swift compiler will output this in the symbol graph JSON:

"availability":[{"domain":"macCatalystAppExtension","isUnconditionallyUnavailable":true},{"domain":"iOSAppExtension","isUnconditionallyUnavailable":true}]

And Swift-DocC will mark it as deprecated in the docs data JSON:

{"deprecated":true,"role":"symbol","title":"MyClass","fragments":[...]}

I think the issue is that the AvailabilityParser marks a symbol as deprecated if every Availability entry for a symbol is marked as isUnconditionallyUnavailable, even if the symbol is implicitly available in other domains. This final check seems incorrect:

        // Check if the symbol is unconditionally deprecated
        return availability.availability
            .allSatisfy { $0.isUnconditionallyDeprecated || $0.isUnconditionallyUnavailable || $0.deprecatedVersion != nil }

DocC already checks if a "universal deprecation" exists (a deprecation where domain == nil) just above that line, though I think it should also check if the domain is *.

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

DocC marks it as available, or maybe marks it as "not available in Application Extensions".

Actual behavior

DocC marks the iOSApplicationExtension-unavailable class as Deprecated with a strikethrough effect.
CleanShot 2023-01-04 at 15 08 43@2x

Swift-DocC Version Information

Bundled in Xcode 14.1

Swift Compiler Version Information

swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0
@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 9, 2023

First of all, thank you for submitting such a detailed bug report.

There is a few thing I'd like to confirm:

  1. Did you make "Expected Behavior" and "Actual behavior" swapped by mistake?
  2. In "Swift-DocC Version Information", did you mean bundled in "Xcode 13.1"?

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Jan 9, 2023

Before we fix the issue, in your specific issue, you can workaround by using the following code snippet:

@available(iOSApplicationExtension, unavailable)
@available(iOS 13.0, *) // Or whatever version you like
public class MyClass: NSObject { }

cc @davidme-stripe

@davidme-stripe
Copy link
Author

First of all, thank you for submitting such a detailed bug report.

There is a few thing I'd like to confirm:

  1. Did you make "Expected Behavior" and "Actual behavior" swapped by mistake?

Ah, yep! 🤦 Let me fix that.

  1. In "Swift-DocC Version Information", did you mean bundled in "Xcode 13.1"?

Sorry, typo, I meant 14.1 (Build 14B47b).

Before we fix the issue, in your specific issue, you can workaround by using the following code snippet:

Thanks, we'll try that! And thanks for the quick fix!

@Kyle-Ye
Copy link
Collaborator

Kyle-Ye commented Sep 26, 2023

Confirm to be fixed by #712. This is causing some downstream user(eg. stripe-ios) to use workaround code.

Should we cherry-pick the fix back to release/5.10. CC @franklinsch @mayaepps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants