Ошибка сборки Flutter iOS при запуске установки модуля

Я пытаюсь создать плагин флаттера, поэтому я создал плагин, выполнив шаги, указанные на https://flutter.dev/docs/development/packages-and-plugins/developing-packages. Я получаю сообщение об ошибке при попытке запустить пример для iOS. Ниже приведен журнал, который я получаю при запуске примера приложения для iOS.

Кто-нибудь может мне с этим помочь?

Running pod install...
CocoaPods' output:
    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
    -> Fetching podspec for `flutter_plugin` from `.symlinks/plugins/flutter_plugin/ios`

    Resolving dependencies of `Podfile`

    Comparing resolved specification to the sandbox manifest
      A Flutter
      A flutter_plugin

    Downloading dependencies

    -> Installing Flutter (1.0.0)

    -> Installing flutter_plugin (0.0.1)
      - Running pre-install hooks
    [!] Unable to determine Swift version for the following pods:

    - `flutter_plugin` does not specify a Swift version and none of the targets (`Runner`) integrating it has the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:115:in `verify_swift_pods_swift_version'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:37:in `validate!'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:459:in `validate_targets'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:138:in `install!'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command/install.rb:48:in `run'
    /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:22:in `load'
    /usr/local/bin/pod:22:in `<main>'

Error output from CocoaPods:
        [33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
        Consider adding the following to ~/.profile:
Error running pod install

person Amol Gangadhare    schedule 27.02.2019    source источник


Ответы (5)


Исправлено обновлением Flutter и CocoaPods до последней версии и последующим запуском следующей команды

flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
person Paresh Mangukiya    schedule 20.08.2020

Получил проблему. когда мы создаем плагин с помощью команды на терминале, он создает плагин с Java по умолчанию для Android и Objective-C для iOS. Его можно изменить на Kotlin для Android и Swift для iOS с помощью команды, но это добавит поддержку только для android/ и ios/ в корневой папке. Это не меняет пример кода в каталоге example/. Приведенные примеры все еще находятся на Java для Android и Objective-C для iOS. Итак, я создал плагин из Android Studio, я создал поддержку Swift для iOS, отметив опцию «Включить поддержку Swift для кода ios», он создал пример с swift вместо Objective-C. Тогда вопрос решен.

person Amol Gangadhare    schedule 28.02.2019

Вам необходимо установить версию Swift с flutter_plugin did not specify a Swift version by default

В вашем ios/Podfile добавить

config.build_settings['SWIFT_VERSION'] = '4.1'  # required by simple_permission

Таким образом:

target 'Runner' do
  use_frameworks!  # required by simple_permission
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.1'  # required by simple_permission
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

Вы также можете проверить эту ветку github и это обсуждение stackoverflow для получения дополнительных сведений о почему это произошло.

person Esh    schedule 27.02.2019

Я добавил определяемую пользователем настройку сборки для Runner на уровне проекта с именем SWIFT-VERSION. Больше у меня ничего не работало.

person rgish    schedule 17.11.2020

Не волнуйтесь. Есть простое решение. Создайте этот файл - AppResources / iOS / Podfile и добавьте его в файл.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.0'
     end
   end
end

Вот и установлен SWIFT_VERSION вашего проекта.

person Muhammad Siman    schedule 19.09.2020