deviceplug / btleplug

Rust Cross-Platform Host-Side Bluetooth LE Access Library
Other
781 stars 145 forks source link

Cannot run on M1 series chip macos #394

Open mdddj opened 1 month ago

mdddj commented 1 month ago

I tried to write a Flutter full platform package using flutter_rust_bridge, but encountered some errors

$ flutter run -d macos              
Launching lib/main.dart on macOS in debug mode...
Running pod install...                                           1,337ms
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-0006395034D8801E, name:My Mac }
{ platform:macOS, arch:x86_64, id:00006000-0006395034D8801E, name:My Mac }
Undefined symbols for architecture arm64:
  "_CBAdvertisementDataManufacturerDataKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::hdba26eb3f8ee3663 in libblue_super.a[arm64][199](btleplug-448251af3f53716a.btleplug.27c43d2c259b7feb-cgu.02.rcgu.o)
  "_CBAdvertisementDataServiceDataKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::hdba26eb3f8ee3663 in libblue_super.a[arm64][199](btleplug-448251af3f53716a.btleplug.27c43d2c259b7feb-cgu.02.rcgu.o)
  "_CBAdvertisementDataServiceUUIDsKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::hdba26eb3f8ee3663 in libblue_super.a[arm64][199](btleplug-448251af3f53716a.btleplug.27c43d2c259b7feb-cgu.02.rcgu.o)
  "_CBCentralManagerScanOptionAllowDuplicatesKey", referenced from:
      btleplug::corebluetooth::internal::CoreBluetoothInternal::start_discovery::h0bff35040dd318f1 in libblue_super.a[arm64][206](btleplug-448251af3f53716a.btleplug.27c43d2c259b7feb-cgu.09.rcgu.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

Building macOS application...                                           
Error: Build process failed

I tried running: arch x86_64 flutter run -d macos, but it still reported an error

Launching lib/main.dart on macOS in debug mode...
Undefined symbols for architecture x86_64:
  "_CBAdvertisementDataManufacturerDataKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::hda93919a7d720282 in libblue_super.a[x86_64][201](btleplug-a54b9db37104a373.btleplug.613af88e7d01b4b8-cgu.07.rcgu.o)
  "_CBAdvertisementDataServiceDataKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::hda93919a7d720282 in libblue_super.a[x86_64][201](btleplug-a54b9db37104a373.btleplug.613af88e7d01b4b8-cgu.07.rcgu.o)
  "_CBAdvertisementDataServiceUUIDsKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::hda93919a7d720282 in libblue_super.a[x86_64][201](btleplug-a54b9db37104a373.btleplug.613af88e7d01b4b8-cgu.07.rcgu.o)
  "_CBCentralManagerScanOptionAllowDuplicatesKey", referenced from:
      btleplug::corebluetooth::internal::CoreBluetoothInternal::start_discovery::hb1297f91fde48b3c in libblue_super.a[x86_64][209](btleplug-a54b9db37104a373.btleplug.613af88e7d01b4b8-cgu.15.rcgu.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture arm64:
  "_CBAdvertisementDataManufacturerDataKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::h05528808b1892d07 in libblue_super.a[arm64][202](btleplug-776761c87c930a08.btleplug.7480da08f29c837e-cgu.05.rcgu.o)
  "_CBAdvertisementDataServiceDataKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::h05528808b1892d07 in libblue_super.a[arm64][202](btleplug-776761c87c930a08.btleplug.7480da08f29c837e-cgu.05.rcgu.o)
  "_CBAdvertisementDataServiceUUIDsKey", referenced from:
      btleplug::corebluetooth::central_delegate::CentralDelegate::delegate_centralmanager_diddiscoverperipheral_advertisementdata_rssi::h05528808b1892d07 in libblue_super.a[arm64][202](btleplug-776761c87c930a08.btleplug.7480da08f29c837e-cgu.05.rcgu.o)
  "_CBCentralManagerScanOptionAllowDuplicatesKey", referenced from:
      btleplug::corebluetooth::internal::CoreBluetoothInternal::start_discovery::h5762f5f729ae9df9 in libblue_super.a[arm64][203](btleplug-776761c87c930a08.btleplug.7480da08f29c837e-cgu.06.rcgu.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

Building macOS application...                                           
Error: Build process failed
qdot commented 1 month ago

I vaguely remember running into this when building another flutter app that uses this library. I'll have to dig through my project and see if I can find what setting I used to fix it, because I'm building fine on m1 now.