RxBluetoothKit icon indicating copy to clipboard operation
RxBluetoothKit copied to clipboard

iOS 15 support

Open chamira-at opened this issue 3 years ago • 11 comments

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.

chamira-at avatar Sep 02 '21 11:09 chamira-at

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 02 '21 11:09 CLAassistant

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.

CSolanaM avatar Sep 23 '21 15:09 CSolanaM

Likewise @CSolanaM ! Friendly nudge @robnadin ;)

gudlaugurellert avatar Sep 24 '21 05:09 gudlaugurellert

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 🙃

robnadin avatar Sep 24 '21 10:09 robnadin

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

gudlaugurellert avatar Oct 05 '21 06:10 gudlaugurellert

can you please have a look on this PR ?

MishkaBalu avatar Oct 13 '21 14:10 MishkaBalu

@monikamsc Can you please help us reviewing this PR?

chamira-at avatar Nov 24 '21 21:11 chamira-at

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 🙏🏼

chamira-at avatar Dec 16 '21 08:12 chamira-at

Hello, Will this be released at some point?

mattiriihimaki avatar Mar 15 '22 08:03 mattiriihimaki

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

fraune avatar Dec 08 '22 20:12 fraune