Adding a watch app to a Flutter iOS application

北城余情 提交于 2019-12-30 06:29:23

问题


I have come across an issue when trying to create a Flutter iOS app with a watch app extension.

For testing I have simply created a default Flutter app using

flutter create watchapp

When this is run I get the standard demo Flutter app.

If I then open the ios/Runner.xcworkspace project in Xcode and add a new target to the project (File->New->Target) and selecting watchOS->Watchkit App it will generate the watch app.

The problem I have come across is when running the app again (with flutter run) I get the following error.

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

I am looking at building a Flutter plugin that will communicate with a Watch app but unless I can get Flutter to run with an added watch app there is not a lot of point.

Does anyone have any suggestions?

Flutter: 0.9.4, Xcode: 10.0

update: Just for clarity I am adding the WatchApp as a new target in the Runner project as a Swift app, I am not looking at using Flutter/Dart to create the WatchApp.


回答1:


Flutter doesn't support Apple Watch apps due to the fact that it lacks Bitcode support for iOS as discussed in this GitHub issue.

You can track the state of Adding Bitcode support for iOS - Flutter GitHub issue, but currently it seems to have a low priority for the Flutter development team.



来源:https://stackoverflow.com/questions/53048589/adding-a-watch-app-to-a-flutter-ios-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!