I try to create a Flutter app with android and apple watch support. For android i don't have problems so far. But I'm struggling with apple watch.
I followed the official instruction from flutter: https://docs.flutter.dev/development/platform-integration/ios/apple-watch. If I see it right, we don't have to enable Bitcode anymore because since Xcode 14 Bitcode is deprecated. But anyway, i tried it with enabling and without enabling Bitcode. Both ways run into the same error.
After I added the Watch App as a Target I get these Errors:
Could not build the precompiled application for the device.
Error (Xcode): unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphoneos'
Error (Xcode): Couldn't look up product type 'com.apple.product-type.watchkit2-extension' in domain 'iphoneos': Couldn't load spec with identifier 'com.apple.product-type.watchkit2-extension' in domain 'iphoneos'
Error (Xcode): unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphoneos'
Error (Xcode): Couldn't look up product type 'com.apple.product-type.application.watchapp2' in domain 'iphoneos': Couldn't load spec with identifier 'com.apple.product-type.application.watchapp2' in domain 'iphoneos'
Googleing this errors leaded me to this stackoverflow question and answer from 'karim'.
In my case, most of the things were ok when I add watchkit extension with xcode 7. but debug target of the extension was iOS. So when I run in debug/simulator I got this error. I have to change them to WatchOS. and Solved. Select Project > Targets > Supported Platform > Debug > watchOS (I had iOS here).
Checking my Supported Platforms, i saw that for my watch targets at 'Supported Platforms' it was also 'watchOS' for 'Debug' but for 'Profile' and 'Release' it was 'iphoneos'
I changed 'Profile' and 'Release' to 'watchOS'. Running with this changes, i get only three of the previous errors:
Could not build the precompiled application for the device.
Error (Xcode): unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphoneos'
Error (Xcode): unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphoneos'
Error (Xcode): Couldn't look up product type 'com.apple.product-type.application.watchapp2' in domain 'iphoneos': Couldn't load spec with identifier 'com.apple.product-type.application.watchapp2' in domain 'iphoneos'
And at this point, I stuck... I don't know how to continue.
I found this guide and example that runs fine. But flutter shows an warning that parts of the code are already deprecated. I can't figure out what are the differences that makes his project run and my is having problems with...
https://github.com/theamorn/flutter-apple-watch
Can someone help? Thanks in advance! :)
Edit 1 - 19.9.2022
Okay, the code of the example I talked about above, is not deprecated, just needs a small migration. The original warning was:
This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future building failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
What I just needed to do was to change in the AndroidMainifest.xml:
<application
android:name="io.flutter.app.FlutterApplication"
to:
<application
android:name="${applicationName}"
like here described:
How to Fix Flutter Warning: Your Flutter application is created using an older version
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
But that still doesn't solve my original problem. I don't want to build my app based of the example project. I would like to start at an entire new flutter project and add a Apple Watch as target. I still can't figure out what are the differences between a new created project based on the flutter instruction and the working example project...
Edit 2 - 20.9.2022
Thanks to the Answer of @Einzeln , I noticed that my config ui layout looks different to his.
So I checked for Updates on all Programms that are needed.
Just for clarification what I have installed now after the update:
- Flutter 3.3.2 - channel stable
- Dart 2.18.1
- DevTools 2.15.0
- Android Studio Dolphin | 2021.3.1
- Xcode Version 14.0
First different that I notice is that the file structure is different if I add a watch as target:
There is only on directory for the watch and not like before I updated ,and also in the example that I talked earlier, that there were two directory. One labeled 'watch' and the other 'watch extension'.
Thanks to @Einzelns answer I also checked the configuration. I had to manually add the watch to my 'Runner' app at 'Frameworks, Libraries, and Embedded Content'.
At the 'watch' I didn't need to add the Runner app there.
But I had to add the 'WatchKit Companion App Bundle Identifier' for the 'watch' at Build Settings -> Info.plist Values.

Starting both apps (watch app and smartphone app) from Xcode is working without any problems.
But starting the Flutter Project / App form Android Studio and also from terminal with 'flutter run' or 'flutter run --release' is leading me to this following problem:
Why is it working fine starting from Xcode but has problems starting from flutter? For me it seems like that the default generated watch app has code that is only available at iOS 14 and newer. Here is the generated default code:
But probably I can work from here on and 'just' need to recreate the code so, that it is also supported by older iOS versions.








