使用 iOS SDK 创建 NativeScript 插件会导致 'Undefined symbols for architecture' 错误
Creating NativeScript Plugin using iOS SDK results in 'Undefined symbols for architecture' errors
我正在尝试创建 NativeScript 插件,以便将蓝牙打印机的 iOS SDK 集成到 NativeScript 应用程序。
这里是 link 到 SDK as Static Framework
我不断收到以下错误,army7
部分在全新安装插件后显示不同的值。
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
除了尝试使用官方插件种子插件外,我最终做了以下根据我的研究应该已经足够的:
安装:
1) 在/app 目录下为插件文件创建了一个文件夹(该插件目前仅适用于该项目)。此文件夹具有以下结构:
/app/plugin/src/package.json
/app/plugin/src/platforms/ios/RTPrinterSDK.framework
RTPrinterSDK.framework 有两个文件夹,Headers(有 .h 文件)和 Modules(有 module.modulemap 文件)除了两个文件 Info.plist 和 RTPrinterSDK.a.
2) 我已通过 运行ning tns plugin add app/plugin/src
将插件添加到项目中
3) 我相信现在 tns run ios --bundle
应该 运行 使用插件连接设备上的项目 - 尽管我还没有在应用程序上对插件做任何事情。
完整性检查:
1) lipo -info app/plugin/src/platforms/ios/RTPrinterSDK.framework/RTPrinterSDK
显示 Architectures in the fat file: /path-to-RTPrinterSDK are: army7 i386 x64_64 arm64
.
2) tns run ios --bundle
没有自定义插件在模拟器和真实设备中都可以工作
3) 为了以防万一,我也在一个全新的 --ts
项目中尝试过这个
4) SDK 附带了一个演示应用程序。虽然它不是 NativeScript 应用程序,但它是一个 Xcode 项目文件,我能够在同一台连接的设备上成功 运行 它。
SDK 中有一条注释引用了 ble_serial.plist
文件。根据说明,我确信我需要将它集成到插件文件夹中的某个位置以访问蓝牙连接,但我不确定在哪里。鉴于错误是指名称中带有 "Ble"
的模块,我担心可能存在连接。
请注意,我没有 write/prepare SDK。打印机的供应商提供了它。我只能访问它提供的内容。
对于有关此问题的任何提示或反馈,我将不胜感激。
根据 NativeScript 社区的宝贵建议,我发现错误中的 CB
前缀指的是 CoreBluetooth
。
为了确保加载它,我最终在 /app/plugin/src/platforms/ios/build.xcconfig
创建了一个新文件并向其中添加了以下行:
OTHER_LDFLAGS = $(inherited) -framework "CoreBluetooth"
。
现在可以在设备上编译运行了。
我正在尝试创建 NativeScript 插件,以便将蓝牙打印机的 iOS SDK 集成到 NativeScript 应用程序。
这里是 link 到 SDK as Static Framework
我不断收到以下错误,army7
部分在全新安装插件后显示不同的值。
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
除了尝试使用官方插件种子插件外,我最终做了以下根据我的研究应该已经足够的:
安装:
1) 在/app 目录下为插件文件创建了一个文件夹(该插件目前仅适用于该项目)。此文件夹具有以下结构:
/app/plugin/src/package.json
/app/plugin/src/platforms/ios/RTPrinterSDK.framework
RTPrinterSDK.framework 有两个文件夹,Headers(有 .h 文件)和 Modules(有 module.modulemap 文件)除了两个文件 Info.plist 和 RTPrinterSDK.a.
2) 我已通过 运行ning tns plugin add app/plugin/src
3) 我相信现在 tns run ios --bundle
应该 运行 使用插件连接设备上的项目 - 尽管我还没有在应用程序上对插件做任何事情。
完整性检查:
1) lipo -info app/plugin/src/platforms/ios/RTPrinterSDK.framework/RTPrinterSDK
显示 Architectures in the fat file: /path-to-RTPrinterSDK are: army7 i386 x64_64 arm64
.
2) tns run ios --bundle
没有自定义插件在模拟器和真实设备中都可以工作
3) 为了以防万一,我也在一个全新的 --ts
项目中尝试过这个
4) SDK 附带了一个演示应用程序。虽然它不是 NativeScript 应用程序,但它是一个 Xcode 项目文件,我能够在同一台连接的设备上成功 运行 它。
SDK 中有一条注释引用了 ble_serial.plist
文件。根据说明,我确信我需要将它集成到插件文件夹中的某个位置以访问蓝牙连接,但我不确定在哪里。鉴于错误是指名称中带有 "Ble"
的模块,我担心可能存在连接。
请注意,我没有 write/prepare SDK。打印机的供应商提供了它。我只能访问它提供的内容。
对于有关此问题的任何提示或反馈,我将不胜感激。
根据 NativeScript 社区的宝贵建议,我发现错误中的 CB
前缀指的是 CoreBluetooth
。
为了确保加载它,我最终在 /app/plugin/src/platforms/ios/build.xcconfig
创建了一个新文件并向其中添加了以下行:
OTHER_LDFLAGS = $(inherited) -framework "CoreBluetooth"
。
现在可以在设备上编译运行了。