12

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.

Steve
  • 557
  • 5
  • 17

2 Answers2

13

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.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • Thanks, but I am not looking to create a WatchOS app in Flutter/Dart. The watch app is added as a swift app to the iOS Runner project, which, at least I think, should be possible. I have added other extensions to a Flutter iOS app this way such as a keyboard extension, but for some reason the Watch app is not working. – Steve Oct 30 '18 at 17:00
  • Apologies, I did not read right down the links you suggested , I understand now - "In an Add2App scenario, anyone using Flutter in their app can no longer use bitcode, and all targets/projects in their workspace will have to disable it." – Steve Oct 30 '18 at 17:03
  • 4
    Just in case anyone is interested I have now managed to create and publish to the AppStore a Flutter app with an associated Watch Kit app. Source for the app is [here](https://github.com/magnatronus/flutter-watchtips) – Steve Feb 05 '19 at 16:47
  • @Steve I am currently trying to add a Today Extension to my flutter app and seem to be having a similar issue (described here: https://github.com/flutter/flutter/issues/29531) do you have any input on how to solve this? – Nick Mowen Mar 18 '19 at 06:00
  • @NickMowen I have added a comment to your github issue – Steve Mar 20 '19 at 07:58
  • 5
    FWIW the Flutter team appears to have added Bitcode support in their master branch, and only for release builds. – Daniel Allen Sep 03 '19 at 12:34
  • @Steve I need to do the same but my project has plugins so there is a Podfile and it tries to link the frameworks of the plugins to the WatchOS Extesnion (and fails) – AR89 Apr 28 '20 at 19:43
4

looks like apple watch development is supported in flutter now. here is an example:

https://github.com/magnatronus/flutter-watchtips

kavehmb
  • 9,822
  • 1
  • 19
  • 22