ios - 将 watch 应用程序添加到 Flutter iOS 应用程序

标签 ios swift flutter watchkit watchapp

我在尝试使用 watch 应用扩展创建 Flutter iOS 应用时遇到了一个问题。

为了测试,我简单地使用

创建了一个默认的 Flutter 应用程序
flutter create watchapp

当它运行时,我得到了标准的演示 Flutter 应用程序。

如果我随后在 Xcode 中打开 ios/Runner.xcworkspace 项目并向项目中添加一个新目标(File->New->Target)并选择 watchOS->Watchkit App,它将生成 watch 应用。

我遇到的问题是再次运行应用程序(使用 flutter 运行)时出现以下错误。

Xcode build done.                                            1.2s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET mywatch Extension OF PROJECT Runner WITH CONFIGURATION 
Debug ===
target specifies product type 'com.apple.product-type.watchkit2-extension', but there's no such product type for the 'iphoneos' platform

我正在考虑构建一个与 Watch 应用程序通信的 Flutter 插件,但除非我可以让 Flutter 与添加的 watch 应用程序一起运行,否则没有什么意义。

有人有什么建议吗?

flutter :0.9.4, Xcode:10.0

更新:为了清楚起见,我将 WatchApp 作为 Runner 项目中的新目标添加为 Swift 应用程序,我不打算使用 Flutter/Dart 来创建 WatchApp。

最佳答案

Flutter 不支持 Apple Watch 应用,因为它缺乏对 iOS 的 Bitcode 支持,如 this GitHub issue 中所述。 .

您可以跟踪为 iOS 添加 Bitcode 支持的状态 - Flutter GitHub issue ,但目前它似乎对 Flutter 开发团队的优先级较低。

关于ios - 将 watch 应用程序添加到 Flutter iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53048589/

相关文章:

flutter - 与使用 firebase_auth 和 flutter_localizations 包的冲突

flutter - 导航器使用 pushNamed 传递参数

ios - 设置 Core Plot 饼图图例项目的样式

ios - 按钮标签自动更改

objective-c - Objective-C 中的调解器模式 : Controller objects to perform calculations etc.

swift - 编译器不允许我比较类型

ios - 基于 Swift NSLayoutConstraint 方程的常量

swift - SKShapeNode 填充颜色比较

swift - 使用 IBM Swift Sandbox 和 rangeOfCharacterFromSet

dart - 无效参数 : The source must not be null