1

I am trying to create a NativeScript plugin in order to integrate an iOS SDK of a bluetooth printer to a NativeScript application.

Here is the link to the SDK as Static Framework

I keep getting the following error with the army7 part showing different values after fresh install of the plugin.

Undefined symbols for architecture armv7:
  "_CBCentralManagerScanOptionAllowDuplicatesKey", referenced from:
      -[RTBleService startScan:serviceArray:clear:] in RTPrinterSDK(RTBleService.o)
  "_OBJC_CLASS_$_CBCentralManager", referenced from:
      objc-class-ref in RTPrinterSDK(RTBleService.o)
  "_OBJC_CLASS_$_CBUUID", referenced from:
      objc-class-ref in RTPrinterSDK(RTBleService.o)
ld: symbol(s) not found for architecture armv7
note: Using new build systemnote: Planning buildnote: Constructing build description

In addition to trying to use the official plugin seed plugin, I have ultimately done the following which according to my research should have been enough:

INSTALLATION:

1) Created a folder for the plugin files within the /app directory (this plugin is only intended for this project at present). This folder has the following structure:

/app/plugin/src/package.json   
/app/plugin/src/platforms/ios/RTPrinterSDK.framework  

The RTPrinterSDK.framework has two folders, Headers (has .h files) and Modules (has the module.modulemap file) in addition to two files being Info.plist and RTPrinterSDK.a.

2) I have added the plugin to the project by running tns plugin add app/plugin/src

3) I believe now tns run ios --bundle should run the project on the connected device with the plugin - albeit I have not done anything with the plugin yet on the application.

SANITY CHECKS:

1) lipo -info app/plugin/src/platforms/ios/RTPrinterSDK.framework/RTPrinterSDK displays that the Architectures in the fat file: /path-to-RTPrinterSDK are: army7 i386 x64_64 arm64.

2) tns run ios --bundle without the custom plugin works both in emulators and real device

3) just in case, I have also attempted this on a fresh new --ts project

4) there is a demo application that comes with the SDK. Whilst it is not a NativeScript application, it is an Xcode project file and I was able to successfully run it on the same connected device.

There is a note in the SDK referring to a ble_serial.plist file. As per the instructions, I am confident that I need to integrate this to somewhere within the plugin folder to access bluetooth connectivity but I am not sure where. Given that the errors are referring to modules with "Ble" in the name, I fear there might be a connection.

Please note that I did not write/prepare the SDK. The vendor of the printer provided it. I only have access to it as it is provided.

I would hugely appreciate any tips or feedback regarding this issue.

HakBon
  • 63
  • 1
  • 9
  • I guess you are using a custom framework, have you compiled it as universal? – Manoj Jun 20 '19 at 20:12
  • @Manoj it sounds like OP doesn't have the original source code; a vendor provided this SDK as-is and that's all we have to work with. – Jamie Birch Jun 20 '19 at 20:35
  • I am afraid @JamieBirch is right as it is also highlighted in the question. _Please note that I did not write/prepare the SDK. The vendor of the printer provided it. I only have access to it as it is provided._ – HakBon Jun 20 '19 at 22:04

1 Answers1

2

Following valuable advice from the NativeScript community, I discovered that the CB prefix in the errors refer to CoreBluetooth.

In order to ensure that it is loaded I ended up creating a new file at /app/plugin/src/platforms/ios/build.xcconfig and adding the following line to it:

OTHER_LDFLAGS = $(inherited) -framework "CoreBluetooth".

It compiles and runs on device now.

HakBon
  • 63
  • 1
  • 9