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

typealias file seems to hide KVO properties #10

Open
DrAma999 opened this issue Jun 29, 2020 · 4 comments
Open

typealias file seems to hide KVO properties #10

DrAma999 opened this issue Jun 29, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@DrAma999
Copy link
Contributor

DrAma999 commented Jun 29, 2020

Hello,
I've added as swift package dependency CoreBluetoothMock library and added as suggested the CoreBluetoothTypeAliases.swift to the project. Removed any reference to import CoreBluetooth in my framework project.
Everything seems ok, but I get an complire error here:

  let peripheralStatePublisher: AnyPublisher<PeripheralState, Never>
    
    init(_ peripheral: CBPeripheral) {
        self.cbPeripheral = peripheral
        self.peripheralStatePublisher = self.cbPeripheral.publisher(for: \.state)
            .map{ (state) -> PeripheralState in
                PeripheralState(state: state)
            }
            .share()
            .eraseToAnyPublisher()
        self.cbPeripheral.delegate = self.peripheralProxy
    }

What I'm trying to do is to leverage KVO and combine capabilities to create a publisher for peripheral state changes.
At the line where I try to get the publisher I get Value of type 'CBPeripheral' (aka 'CBMPeripheral') has no member 'publisher'.
I've tried also to import Foundation and Combine in the alias file, but I still get this error.
I'm using Xcode 11.5 and the 0.8.0 version of the library.

@DrAma999
Copy link
Contributor Author

DrAma999 commented Jul 4, 2020

After further investigation, is not due to aliases, but the issue is due to the nature protocol of the mock CMBPeripheral.

@philips77
Copy link
Member

philips77 commented Jul 4, 2020

Yes, the original CBPeripheral is a class, while in this library, theCBMPeripheral is a protocol. For the same reason it's not Hashable or Equatable.
Regarding the publish, I could add those methods to the protocol, but the other protocols are more problematic.

@DrAma999
Copy link
Contributor Author

DrAma999 commented Jul 8, 2020

Yes, the original CBPeripgeral is a class, while in this library, theCBMPeripheral is a protocol. For the same reason it's not Hashable or Equatable.
Regarding the publish, I could add those methods to the protocol, but the other protocols are more problematic.

It would be wonderful, to test that functionality I made a little trick, but I'm not liking it that much.
May I say that this project is simply amazing!. I'm trying to build a CB library , sort of Polidea RX Bluetooth but with combine and is helping me a lot in creating a good unit test coverage.
Thank you!

@philips77
Copy link
Member

@NickKibish, how is this issue related to #96? Is it fixed, or 96 solves just few cases?

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

No branches or pull requests

2 participants