ObjC compatibility

Hi,

I've finally been able to install and build the new API, 3.1.6. However, it doesn't seem fully compatible with an ObjC project, ie. the MetaWear-Swift bridging header doesn't supply the necessary methods in order to actually use the API. I'm wondering if there is continuing support for the ObjC API and, if not, whether compatibility will be improved within the Swift API to support ObjC projects.

Thanks,

--Alex

Comments

  • We are moving away from Obj-C in place of Swift as preferred by Apple.

    Please make sure to use the latest API 3.1.6 which is fully compatible.
    3.1.6 is a Swift wrapper on top of our MetaWear C libraries.

    If you have specific integration issues with 3.1.6, please post your errors with supporting evidence (image/snapshot/screen-grab/code snippet/xcode error).

    Also, please make sure to update XCODE; this could be your issue.

    Thanks,
    -Laura

  • Thanks Laura, my XCode is the latest official release (9.4.1). That isn't the issue. The issue is that the Metawear Swift framework doesn't expose any useful functionality to ObjC. Simply look at the Swift brigding header in the framework. These are the methods actually exposed to ObjC that can be used by an ObjC caller.

    /// Scanner utility, make is simple to start scanning for MetaWear devices without
    /// having to understand all of CoreBluetooth
    SWIFT_CLASS("_TtC8MetaWear15MetaWearScanner")
    @interface MetaWearScanner : NSObject
    - (nonnull instancetype)init SWIFT_UNAVAILABLE;
    + (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
    @end
    
    @class CBCentralManager;
    
    @interface MetaWearScanner (SWIFT_EXTENSION(MetaWear)) <CBCentralManagerDelegate>
    - (void)centralManagerDidUpdateState:(CBCentralManager * _Nonnull)central;
    - (void)centralManager:(CBCentralManager * _Nonnull)central didDiscoverPeripheral:(CBPeripheral * _Nonnull)peripheral advertisementData:(NSDictionary<NSString *, id> * _Nonnull)advertisementData RSSI:(NSNumber * _Nonnull)RSSI;
    - (void)centralManager:(CBCentralManager * _Nonnull)central didConnectPeripheral:(CBPeripheral * _Nonnull)peripheral;
    - (void)centralManager:(CBCentralManager * _Nonnull)central didFailToConnectPeripheral:(CBPeripheral * _Nonnull)peripheral error:(NSError * _Nullable)error;
    - (void)centralManager:(CBCentralManager * _Nonnull)central didDisconnectPeripheral:(CBPeripheral * _Nonnull)peripheral error:(NSError * _Nullable)error;
    - (void)centralManager:(CBCentralManager * _Nonnull)central willRestoreState:(NSDictionary<NSString *, id> * _Nonnull)dict;
    @end
    

    You'll see that none of the discovery functionality is actually available. So if you try to use this in ObjC code, you get the following.

    The same applies to the MetaWear class which doesn't expose any useful methods for connecting to the sensor and reading measurements from it. If I'm doing something wrong, please post an ObjC starter project that uses the new API, but I' pretty sure it's not possible given the current API.

    Thanks,

    --Alex

Sign In or Register to comment.