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

Integration with AccessorySetupKit #49

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

Conversation

Supereg
Copy link
Member

@Supereg Supereg commented Sep 11, 2024

Integration with AccessorySetupKit

♻️ Current situation & Problem

With iOS 18, Apple introduced a new way of pairing and accessing Bluetooth accessories in a more privacy preserving way where the user can explicitly allow access to individual accessories. It includes additional UI components to present product images and human-readable names that are also shown in the settings app.

SpeziBluetooth adds first-hand support to interact with AccessorySetupKit. The new AccessorySetupKit module makes it easy to interact with AccessorySetupKit with more modern Swift paradigms. Further, it allows to easily access some state like pickerPresented that supports SwiftUI observability out of the box.

Additional, SpeziBluetooth types like DiscoveryCriteria or ManufacturerIdentifier can be easily converted to AccessorySetupKit types like ASDiscoveryDescriptor and ASCompanyIdentifier. Further, DiscoveryCriteria got additional supports for criteria that is supported by ASKit like matching for service data or manufacturer data by specifying a DataDescriptor.

Further, we add native support for a BluetoothDevice to define its DeviceAppearance which also supports to distinguish appearance by different Variants. You use a DeviceVariantCriteria to distinguish a physical Bluetooth device from other variants. DeviceVariantCriteria has native support to apply it to a ASDiscoveryDescriptor. This allows to easily build your ASPickerDisplayItems to present the AccessorySetupKit picker UI.

⚙️ Release Notes

  • Add a AccessorySetupKit Spezi Module for easier interaction with AccessorySetupKit.
  • Add extensions to easily bridge DiscoveryCriteria and ManufacturerIdentifier to their AccessorySetupKit counterparts.
  • Added a new DeviceApperance model that lets you declare how physical devices of your BluetoothDevice implementation look like. These appearances can be easily mapped to a AccessorySetupKit ASDiscoveryDescriptor and ASPickerDisplayItem to have easy integration with AccessorySetupKit.
  • The SpeziBluetooth package now supports visionOS, tvOS and watchOS.
  • Move some infrastructure to SpeziFoundation.

📚 Documentation

The documentation catalog was updated and added two new articles around CoreBluetooth and AccessorySetupKit to make the landing page less cluttered and highlight the SpeziBluetooth DSL more clearly.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

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

Thank you for all the improvements here and incorporating AccessorySetupKit[ very cool to see that we already have a decent overlap here!

I only had a few smaller comments. Once we have resolved the SwiftLint errors, remaining TODOs we should be good to go. The only element that requires more attention would be the Swift6 actor issue with the requirement to trigger updates on the UI using @MainActor; wondering if this or an other PR is the place to address this?

@PSchmiedmayer PSchmiedmayer added the enhancement New feature or request label Oct 21, 2024
@Supereg Supereg force-pushed the feature/accessory-setup-kit branch from 4050bb1 to c05d769 Compare November 6, 2024 17:37
@Supereg Supereg force-pushed the feature/accessory-setup-kit branch from c05d769 to 0dcea17 Compare November 6, 2024 17:42
@Supereg Supereg marked this pull request as ready for review November 7, 2024 18:01
Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

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

The build errors will be resolved with #51; we should merge #51 first and then merge main into this branch 👍

Copy link

codecov bot commented Nov 10, 2024

Codecov Report

Attention: Patch coverage is 15.36797% with 782 lines in your changes missing coverage. Please review.

Project coverage is 71.24%. Comparing base (4d64dfa) to head (e00b547).

Files with missing lines Patch % Lines
...luetooth/AccessorySetupKit/AccessorySetupKit.swift 0.00% 198 Missing ⚠️
...oreBluetooth/Configuration/DiscoveryCriteria.swift 10.53% 119 Missing ⚠️
...oth/AccessorySetupKit/AccessorySetupKitError.swift 0.00% 100 Missing ⚠️
...CoreBluetooth/Configuration/DescriptorAspect.swift 18.61% 70 Missing ⚠️
...upKit/DescriptorAspect+ASDiscoveryDescriptor.swift 0.00% 57 Missing ⚠️
...orySetupKit/ASAccessoryEventType+Description.swift 0.00% 35 Missing ⚠️
...onfiguration/Apperance/DeviceVariantCriteria.swift 0.00% 26 Missing ⚠️
...cessorySetupKit/DiscoveryCriteria+Descriptor.swift 0.00% 23 Missing ⚠️
...oth/Configuration/Apperance/DeviceAppearance.swift 0.00% 22 Missing ⚠️
...AccessorySetupKit/AccessoryEventRegistration.swift 0.00% 19 Missing ⚠️
... and 17 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
- Coverage   80.16%   71.24%   -8.92%     
==========================================
  Files         111      125      +14     
  Lines        6053     6672     +619     
==========================================
- Hits         4852     4753      -99     
- Misses       1201     1919     +718     
Files with missing lines Coverage Δ
...ooth/Configuration/DeviceDiscoveryDescriptor.swift 76.93% <100.00%> (ø)
...ources/SpeziBluetooth/Configuration/Discover.swift 100.00% <ø> (ø)
...oth/Configuration/DiscoveryDescriptorBuilder.swift 45.84% <100.00%> (ø)
...tooth/CoreBluetooth/Model/GATTCharacteristic.swift 70.74% <ø> (ø)
...etooth/CoreBluetooth/Model/PeripheralStorage.swift 82.36% <100.00%> (-1.54%) ⬇️
...th/CoreBluetooth/Utilities/BluetoothWorkItem.swift 100.00% <100.00%> (ø)
...eziBluetooth/Model/Properties/Characteristic.swift 90.33% <ø> (ø)
...th/Modifier/BluetoothScanningOptionsModifier.swift 0.00% <ø> (ø)
...Bluetooth/Modifier/ScanNearbyDevicesModifier.swift 71.12% <ø> (ø)
...rtySupport/CharacteristicPeripheralInjection.swift 60.67% <0.00%> (ø)
... and 26 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d64dfa...e00b547. Read the comment docs.

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
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Move ManagedAsynchronousAccess to SpeziFoundation Move RWLock to SpeziFoundation
2 participants