Flutter_tts 运行 iOS

Flutter_tts doesn't run on iOS

我正在尝试使用 Flutter_tts 库编写一个在 flutter 上朗读文本的应用程序,它在 android 上工作正常,但是当我尝试 运行 它在 iOS 设备我得到一个错误:

 === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    ld: warning: Could not find auto-linked library 'swiftDispatch'
    ld: warning: Could not find auto-linked library 'swiftCoreMedia'
    ld: warning: Could not find auto-linked library 'swiftAVFoundation'
    ld: warning: Could not find auto-linked library 'swiftFoundation'
    ld: warning: Could not find auto-linked library 'swiftsimd'
    ld: warning: Could not find auto-linked library 'swiftObjectiveC'
    ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
...
我之前将我的构建系统切换到旧版构建系统并将我的 "Swift Language Version" 指定为 "Swift 4.2"

当我将我的构建系统切换到 "New Build System" 时,它给了我

Xcode's output:
↳
    error: Multiple commands produce '/Users/dimazhylko/FlutterProjects/flutter_tts_plugin_test/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework':
    1) Target 'Runner' has copy command from '/Users/dimazhylko/FlutterProjects/flutter_tts_plugin_test/ios/Flutter/Flutter.framework' to '/Users/dimazhylko/FlutterProjects/flutter_tts_plugin_test/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework'
    2) That command depends on command in Target 'Runner': script phase “[CP] Embed Pods Frameworks”
    warning: Not running swift-stdlib-tool: ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES is enabled, but the product type 'com.apple.product-type.library.static' is not a wrapper type. (in target 'Pods-Runner')
    warning: ignoring duplicated output file: '/Users/dimazhylko/FlutterProjects/flutter_tts_plugin_test/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework' (in target 'Runner')
    note: Using new build systemnote: Planning buildnote: Constructing build description

降级 Swift 版本也无济于事。

我还能尝试什么来解决这个问题? 或者你可以推荐另一个库?(我已经试过 Tts 但它看起来不是一个好的选择,因为它只适用于 flutter v"0.5.0"(Dart 版本 2.0.0<)

I also get this warning when I open Xcode

这是一个已知问题https://github.com/flutter/flutter/issues/20685

https://github.com/flutter/flutter/issues/20685#issuecomment-421511890

There are two workarounds:

  • Option 1: Use the legacy build system . As noted by @gi097, open ios/Runner.xcworkspace, and change the build system to Legacy Build System.
  • Option 2: Use the new Xcode 10 build system.
    1. Open ios/Runner.xcworkspace
    2. Select the Runner project in the project navigator sidebar.
    3. In the main view, select the Runner target, then select the Build Phases tab.
    4. Expand the Embed Frameworks phase and select Flutter.framework from the embedded frameworks list.
    5. Click - to remove Flutter.framework from the list (be sure to keep App.framework).

应该已经在 dev and/or master 频道中修复了。

这是在不使用 -i swift 标志的情况下创建 flutter 项目时的一个已知问题。我在这里概述了它 similar issue

flutter create -i swift my_app

作为一个糟糕的解决方法,您可以使用 -i swift 标志创建一个新的 flutter 项目,然后从当前项目复制您的文件。

右键点击Runner,添加一个新的Swift文件。 XCode 会询问您是否要添加桥接头。接受并重新编译。