Добавление цели Apple Watch в приложение Flutter

См. документ Flutter: https://docs.flutter.dev/development/platform-integration/ios/apple-watch.

Прежде всего, вам необходимо следовать инструкциям, приведенным в документе Flutter (ссылка выше).

  1. Включите биткод в Xcode
    Цели Apple Watch требуют включения биткода, поэтому для использования биткода в вашем приложении выполните шаги из раздела Создание приложения с поддержкой биткода iOS.

  2. Добавьте цель Apple Watch
    В меню выберите File > New > Target. Когда откроется диалоговое окно, выберите watchOS в верхней части и нажмите Watch App для iOS App. Нажмите Next, введите имя продукта и выберите Enter.

  3. Когда вы запустите проект с помощью обычной команды flutter run. Вы получите ошибку следующего вида

# flutter run                                                                                                                                                     
Launching lib/main.dart on iPhone 13 Pro in debug mode...
Running Xcode build...                                          
Xcode build done.                                            2.1s
Failed to build iOS app
Error output from Xcode build:
↳
    2022-07-20 23:02:24.107 xcodebuild[18239:137665] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-07-20 23:02:24.108 xcodebuild[18239:137665] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/_6/2nt5c3lx2tbc9bkg1vkb5tfm0000gp/T/flutter_tools.zDoJxh/flutter_ios_build_temp_dirlIvUEW/temporary_xcresult_bundle

    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator' (in target 'watch' from project 'Runner')
    error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator' (in target 'watch' from project 'Runner')
    error: Couldn't look up product type 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator' (in target 'watch' from project 'Runner')
    warning: duplicate output file '' on task: RegisterExecutionPolicyException /Users/gie/Develops/test/flutter/app_watch/build/ios/Debug-iphonesimulator (in target 'watch' from project 'Runner')
    error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'watch WatchKit Extension' from project 'Runner')
    error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'watch WatchKit Extension' from project 'Runner')
    error: Couldn't look up product type 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator' (in target 'watch WatchKit Extension' from project 'Runner')

    Result bundle written to path:
        /var/folders/_6/2nt5c3lx2tbc9bkg1vkb5tfm0000gp/T/flutter_tools.zDoJxh/flutter_ios_build_temp_dirlIvUEW/temporary_xcresult_bundle


Error (Xcode): unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator'

Error (Xcode): Couldn't look up product type 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.application.watchapp2' in domain 'iphonesimulator'

Error (Xcode): unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator'

Error (Xcode): Couldn't look up product type 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator': Couldn't load spec with identifier 'com.apple.product-type.watchkit2-extension' in domain 'iphonesimulator'

Could not build the application for the simulator.
Error launching application on iPhone 13 Pro.
Войти в полноэкранный режим Выйти из полноэкранного режима
  1. Вам нужно обновить расширение WatchKit, предоставив ему идентификатор WKCompanionAppBundleIdentifier с помощью следующего кода:
<key>WKCompanionAppBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
Вход в полноэкранный режим Выйдите из полноэкранного режима

  1. Очистите и запустите проект снова
flutter clean
flutter run
Войти в полноэкранный режим Выйти из полноэкранного режима

Оцените статью
devanswers.ru
Добавить комментарий