gpt4 book ai didi

ios - 如何在 iOS 中使用 flutter_blue?

转载 作者:行者123 更新时间:2023-12-01 19:31:18 28 4
gpt4 key购买 nike

我正在尝试在 iOS 中使用 flutter 和 flutter_blue。
我收到每个 channel 的故障转储。我是新手,所以也许这是一个简单的问题。我知道人们使用这个库,所以它必须在我的使用中。奇怪的是,尽管选择了 channel ,但每次都会产生相同的故障转储。
重现步骤

OSX: Version 0.15.5 (19F101)
Xcode : Version 11.5 (11E608c)
使用主页上的示例和实际的 GitHub src 作为指南。这些网址:
  • https://pub.dev/packages/flutter_blue#-example-tab-
  • https://github.com/pauldemarco/flutter_blue/tree/master/example/lib
  • 指定flutter channel 并更新

  • 我已经尝试了每个 flutter channel 。每个 channel 产生相同的故障转储。
    $ flutter channel stable
    $ flutter upgrade

    Flutter 1.17.4 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 1ad9baa8b9 (9 days ago) • 2020-06-17 14:41:16 -0700
    Engine • revision ee76268252
    Tools • Dart 2.8.4

    $ flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, v1.17.4, on Mac OS X 10.15.5 19F101, locale en-US)

    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    [✓] Android Studio (version 4.0)
    [!] VS Code (version 1.24.1)
    ✗ Flutter extension not installed; install from
    https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    [✓] Connected device (1 available)

    ! Doctor found issues in 1 category.
  • 创建 stub 项目

  • 为简单起见,模仿这个例子。
    $ flutter create flutter_blue_example
    $ cd flutter_blue_example
  • 在 Xcode 中打开项目并进行运行时更改
  • $ open ios/Runner.xcworkspace/
    选择 TARGETS: Runner 然后选择 General 选项卡以修改运行时 API
    General->Deployment Info->Target == iOS 13.5
    选择 TARGETS: Runner,然后选择 Signing & Capabilities 选项卡以修改签名包标识符和团队名称。
    我注意到一些错误消息与 iOS 8.0 与 iOS 10.0 API 功能有关。因此,我选择了最新的 API iOS 13。
  • 正确的包标识符和签名团队名称
  • 通过 Xcode 在手机上运行示例。
  • 停止应用关闭 Xcode。使用 cli 运行。
  • 关闭并用cli测试
    $ flutter run
  • 演示应用程序运行时,按 q 退出
  • 修改 pubspec.yaml 文件,使依赖部分如下所示:
  • dependencies:
    flutter_blue: ^0.7.2
    flutter:
    sdk: flutter
  • 删除 lib/main.dart stub /模板代码并替换为 git repo 中的示例代码。
  • $ cd lib
    $ rm main.dart
    $ curl https://raw.githubusercontent.com/pauldemarco/flutter_blue/master/example/lib/main.dart --output main.dart
    $ curl https://raw.githubusercontent.com/pauldemarco/flutter_blue/master/example/lib/widgets.dart --output widgets.dart
  • 清理并安装依赖项

  • 每次我更改 channel 时,我都会执行相同的过程。
    $ cd ..
    # The rm iOS/Podfile command is only needed when
    # switching to channel dev
    # rm iOS/Podfile
    $ flutter pub get
    $ flutter clean
  • 尝试构建和运行示例代码
  • $ flutter run
    Launching lib/main.dart on JFD_X in debug mode...
    Automatically signing iOS for device deployment using specified development team in Xcode
    project: Z84M4MZYKF
    Running pod install... 1.6s
    Running Xcode build...

    └─Compiling, linking and signing... 14.3s
    Xcode build done. 29.7s
    Installing and launching... ⣻
    在 iPhone 上,它会闪烁显示应用程序启动的屏幕,但很快就会返回主屏幕。提示永远不会返回,必须使用 ctrl-c 退出命令因为 q不响应。
    使用详细选项运行可提供此信息。
    <stuff snipped>
    [ +155 ms] success
    [ ] (lldb) safequit
    [ +109 ms] Process 20400 detached
    [ +30 ms] Application launched on the device. Waiting for observatory port.
    [ +9 ms] Attempting to forward device port 49232 to host port 1024
    [ ] executing: /Users/davis/progs/flutter/flutter/bin/cache/artifacts/usbmuxd/iproxy 1024 49232
    850f92882e33715d639b466a0ba9a01aeb601823
    [+1011 ms] Forwarded port ForwardedPort HOST:1024 to DEVICE:49232
    [ +17 ms] HttpException: Connection closed before full header was received, uri = http://localhost:1024/ws
    [+2008 ms] HttpException: , uri = http://localhost:1024/ws
    [+2007 ms] HttpException: , uri = http://localhost:1024/ws
    [+2008 ms] HttpException: , uri = http://localhost:1024/ws
    [+2011 ms] HttpException: , uri = http://localhost:1024/ws
    [+2006 ms] Failed to connect directly, falling back to mDNS
    [ +5 ms] Checking for advertised Dart observatories...
    [+5020 ms] No pointer records found.
    [ +2 ms] mDNS query failed. Checking for an interface with a ipv4 link local address.
    [ +2 ms] Found interface "en0":
    [ ] Bound address: "192.168.86.53"
    [ ] Found interface "en5":
    [ ] Bound address: "169.254.128.136" link local
    [ ] An interface with an ipv4 link local address was found.
    [ ] Failed to connect with mDNS, falling back to log scanning
    再次打开 xcode 并尝试从 Xcode 运行。
    $ open ios/Runner.xcworkspace/
    运行应用程序,它会提供以下故障转储
    channel 稳定
    libsystem_kernel.dylib`__abort_with_payload:
    0x1b44c97ec <+0>: mov x16, #0x209
    0x1b44c97f0 <+4>: svc #0x80
    -> 0x1b44c97f4 <+8>: b.lo 0x1b44c9810 ; <+36> Thread 3: signal SIGABRT
    0x1b44c97f8 <+12>: stp x29, x30, [sp, #-0x10]!
    0x1b44c97fc <+16>: mov x29, sp
    0x1b44c9800 <+20>: bl 0x1b44a9ad0 ; cerror_nocancel
    0x1b44c9804 <+24>: mov sp, x29
    0x1b44c9808 <+28>: ldp x29, x30, [sp], #0x10
    0x1b44c980c <+32>: ret
    0x1b44c9810 <+36>: ret
    版本检查
    huo-yang~/progs/flutter/flutter-testy/flutter_blue_example$ flutter --version
    Flutter 1.17.4 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 1ad9baa8b9 (12 days ago) • 2020-06-17 14:41:16 -0700
    Engine • revision ee76268252
    Tools • Dart 2.8.4
    channel 测试版
    给出与上面相同的堆栈跟踪。
    版本检查
    huo-yang~/progs/flutter/flutter-testy/flutter_blue_example$ flutter --version
    Flutter 1.19.0-4.2.pre • channel beta • https://github.com/flutter/flutter.git
    Framework • revision 9b9b543d92 (7 days ago) • 2020-06-22 12:19:28 -0700
    Engine • revision 9a28c3bcf4
    Tools • Dart 2.9.0 (build 2.9.0-14.1.beta)
    channel 开发
    给出与上面相同的堆栈跟踪。
    版本检查
    $ flutter run --version
    Flutter 1.20.0-2.0.pre • channel dev • https://github.com/flutter/flutter.git
    Framework • revision 15a28159bc (6 days ago) • 2020-06-23 04:52:58 -0700
    Engine • revision 91a63d6a44
    Tools • Dart 2.9.0 (build 2.9.0-19.0.dev 7e72c9ae7e)

    最佳答案

    我尝试了 flutter_blue 至少两个月,但我无法以任何可靠的方式开始工作。我不想详细介绍,但是您可以在 flutter_blue github 存储库中搜索我的 ID 并获得一张不错的图片。
    我终于切换到flutter_ble_lib https://pub.dev/packages/flutter_ble_lib
    并让我所有的东西都在几天内工作。
    我的代码非常抽象,切换库也没问题。一切都在 Android 和 IOS 上运行。试试看。

    关于ios - 如何在 iOS 中使用 flutter_blue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62638588/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com