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

weak_delegate: @WKExtensionDelegateAdaptor should be non-triggering #3611

Closed
2 tasks done
edorphy opened this issue Apr 25, 2021 · 0 comments · Fixed by #3599
Closed
2 tasks done

weak_delegate: @WKExtensionDelegateAdaptor should be non-triggering #3611

edorphy opened this issue Apr 25, 2021 · 0 comments · Fixed by #3599

Comments

@edorphy
Copy link

edorphy commented Apr 25, 2021

New Issue Checklist

Describe the bug

WKExtensionDelegateAdaptor triggers weak_delegate but should not.

Complete output when running SwiftLint, including the stack trace and command used
% swiftlint
Linting Swift files in current working directory
...
Linting 'Application.swift' (12/14)
...
/Users/username/Developer/Applications/ApplicationName/Sources/Application/Application.swift:19:57: warning: Weak Delegate Violation: Delegates should be weak to avoid reference cycles. (weak_delegate)
Done linting! Found 1 violation, 0 serious in 14 files.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.43.1
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? pkg install
  • Paste your configuration file:
disabled_rules:
  - line_length

trailing_whitespace:
  ignores_empty_lines: true
  • Are you using nested configurations? No
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 12.5 Build version 12E262
  • Do you have a sample that shows the issue? See example below
import SwiftUI

@main
struct Application: App {

    #if os(iOS)

    @UIApplicationDelegateAdaptor(ApplicationDelegate.self) var applicationDelegate

    #elseif os(watchOS)

    @WKExtensionDelegateAdaptor(ExtensionDelegate.self) var extensionDelegate

    #endif

    let persistenceController = PersistenceController.shared

    @SceneBuilder var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(\.managedObjectContext, persistenceController.container.viewContext)
        }

        #if os(watchOS)

        WKNotificationScene(controller: NotificationController.self, category: "myCategory")

        #endif
    }
}
@edorphy edorphy changed the title WKExtensionDelegateAdaptor triggers weak_delegate but should be non-triggering like UIApplicationDelegateAdaptor weak_delegate: @WKExtensionDelegateAdaptor should be non-triggering Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant