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

Leif/dependency improvements #48

Merged
merged 2 commits into from
Dec 7, 2023
Merged

Leif/dependency improvements #48

merged 2 commits into from
Dec 7, 2023

Conversation

0xLeif
Copy link
Owner

@0xLeif 0xLeif commented Dec 7, 2023

This change allows for a trailing closure syntax when creating dependencies. This change also moved the addObserver of the notification NSUbiquitousKeyValueStore.didChangeExternallyNotification from the init to when icloudStore is first initialized.

@available(iOS 15.0, watchOS 9.0, macOS 11.0, tvOS 15.0, *)
extension Application {
    /// The default `NSUbiquitousKeyValueStore` instance.
    public var icloudStore: Dependency<NSUbiquitousKeyValueStore> {
        dependency {
            NotificationCenter.default.addObserver(
                self,
                selector: #selector(didChangeExternally),
                name: NSUbiquitousKeyValueStore.didChangeExternallyNotification,
                object: NSUbiquitousKeyValueStore.default
            )

            return NSUbiquitousKeyValueStore.default
        }
    }
}

This resolves a potential log error when you don't have the correct entitlement file.

Unable to find entitlement for KVS store

BUG IN CLIENT OF KVS: Trying to initialize NSUbiquitousKeyValueStore without a store identifier. Please specify your store identifier in the 'com.apple.developer.ubiquity-kvstore-identifier' entitlement.

@0xLeif 0xLeif added the enhancement New feature or request label Dec 7, 2023
@0xLeif 0xLeif self-assigned this Dec 7, 2023
@0xLeif 0xLeif merged commit b1639ff into main Dec 7, 2023
1 check passed
@0xLeif 0xLeif deleted the leif/DependencyImprovements branch December 7, 2023 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant