Сторонние пакеты Dart в pubspec.yaml приводят к ошибке фатального файла, не найденного в Xcode (но работает на Android)

Я разрабатываю приложение Flutter в Android Studio на MacBook Pro под управлением macOS Mojave. Приложение компилируется и запускается на Android (как на эмуляторе, так и на физическом устройстве), но не компилируется для iOS (как на эмуляторе, так и на физическом устройстве). Он отлично компилируется для обеих платформ, если в pubspec.yaml нет ссылки на 3-ю библиотеку Dart.

Доктор флаттера не показывает никаких ошибок.

Вот мой pubspec.yaml:

name: yr_school_bus_cancellations
description: York Region School Bus Cancellations

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  http: ^0.12.0+1
  html: ^0.13.3+3
  sqflite: ^1.1.0
  path_provider: ^0.5.0+1
  url_launcher: ^5.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages

И сообщение об ошибке в Xcode:

=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
/Users/josephlam/AndroidStudioProjects/2019/yr_school_bus_cancellations/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'path_provider/PathProviderPlugin.h' file not found
#import <path_provider/PathProviderPlugin.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

PathProvider - не единственный пакет, вызывающий проблему. Если я удалю ссылку на PathProvider в pubspec.yaml, сборка не будет выполнена в другом стороннем пакете (например, http, url_launcher, sqflite).

Кто-нибудь знает, как исправить эту проблему? Спасибо!


person Joseph Lam    schedule 19.02.2019    source источник
comment
Вы пробовали flutter clean?   -  person Günter Zöchbauer    schedule 20.02.2019
comment
Проверьте, помогает ли добавление use_frameworks! github.com/flutter/flutter/issues/16049#issuecomment -382629492   -  person Günter Zöchbauer    schedule 20.02.2019
comment
Спасибо, ребята. Я попробовал оба предложения, но проблема не устранена.   -  person Joseph Lam    schedule 20.02.2019
comment
Попробуйте pod install в ios/   -  person Günter Zöchbauer    schedule 20.02.2019


Ответы (1)


Благодаря помощи Гюнтера Цёхбауэра в следующей статье была исправлена ​​проблема для меня: https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#generated-project-files-устаревший.

Ниже репликация содержания статьи:

Когда проект создается с помощью flutter create foo, создается несколько файлов в подкаталогах ios / и android /.

Новые версии Flutter могут генерировать эти файлы немного иначе, а проекты, созданные с использованием более старых версий Flutter, могут вызывать проблемы.

  • Удалите каталоги ios / и android / и запустите flutter create. для повторного создания этих каталогов.

Пользовательские изменения будут потеряны, и их нужно будет применить повторно. Это проще всего, если проект привязан к системе контроля версий, такой как Git.

person Joseph Lam    schedule 20.02.2019