Polidea / RxBluetoothKit

iOS & OSX Bluetooth library for RxSwift
Apache License 2.0
1.41k stars 365 forks source link

iOS 15 support #401

Open chamira-at opened 3 years ago

chamira-at commented 3 years ago

There are some changes to the Core Bluetooth API.

CBService
unowned(unsafe) var peripheral: CBPeripheral { get }

CBCharacteristic
unowned(unsafe) var service: CBService { get }

CBDescriptor
unowned(unsafe) var characteristic: CBCharacteristic { get }
iOS 15.X

CBService
weak var peripheral: CBPeripheral? { get }

CBCharacteristic
weak var service: CBService? { get }

CBDescriptor
weak var characteristic: CBCharacteristic? { get }

The changes are detailed describe here in this issue

Solution:

Made below classes' convenience init(…) methods optional convenience init?(…) and only initialize if pass in params required properties(service, characteristic, descriptors) are not deallocated.

RxBluetoothKit

- Characteristic.swift
- Descriptor.swift

Example

    convenience init?(descriptor: CBDescriptor, peripheral: Peripheral) {

        guard let _characteristic = descriptor.characteristic, let _service = _characteristic.service else {
            return nil
        }

        let service = Service(peripheral: peripheral, service: _service)
        let characteristic = Characteristic(characteristic: _characteristic, service: service)
        self.init(descriptor: descriptor, characteristic: characteristic)
    }

Caller sites have been always guard strogeRefeance therefore, added an extra guard for those that are optionally initializable.

Test

Test cases are update and force unwrapped for those optional initializable objects.

Other improvement

Fixed deprecated method signature warnings.

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

CSolanaM commented 2 years ago

Thank you very much @chamira-at for this PR. A dependency of my project depends on this to unblock me of using the latest Swift version. Looking forward for @robnadin 's review.

gudlaugurellert commented 2 years ago

Likewise @CSolanaM ! Friendly nudge @robnadin ;)

robnadin commented 2 years ago

Likewise @CSolanaM ! Friendly nudge @robnadin ;)

Unfortunately I don't have write access so I'm not able to perform a full review, just thought I'd add my $0.02 to the changes 🙃

gudlaugurellert commented 2 years ago

@minixT friendly nudge! Is there any chance you could have a look at this PR?

MishkaBalu commented 2 years ago

can you please have a look on this PR ?

chamira-at commented 2 years ago

@monikamsc Can you please help us reviewing this PR?

chamira-at commented 2 years ago

Hi 👋🏽,

Can someone with write access have a look at on this PR and approves it :).

It has been sometime and this PR is really critical for many projects.

Really appreciate your guys hard work and Thank you 🙏🏼

mattiriihimaki commented 2 years ago

Hello, Will this be released at some point?

fraune commented 1 year ago

Is there anything I can do to help get this merged in?

RomanPodymov commented 2 months ago

Hello @mpiechocki @minixT Can you merge this, please? The master branch is not compiling in Xcode 15.4.