【问题标题】:Flutter: Unable to remove custom plugin from being included in ios appFlutter:无法从 ios 应用程序中删除自定义插件
【发布时间】:2020-08-05 00:31:40
【问题描述】:

我为 windows 编写了一个自定义的颤振插件,到目前为止效果很好。 但由于某种原因,当我尝试在 iphone 模拟器上运行它时,颤振一直在 ios 构建中包含该插件。这会导致错误,因为插件没有 ios 实现。 在 Android 上一切正常。

这里是插件 pubspec.yaml:

name: fbfunctions
description: A new flutter plugin project.

environment:
  sdk: ">=2.7.0 <3.0.0"
  flutter: ">=1.10.0"

dependencies:
  flutter:
    sdk: flutter

flutter:
  plugin:
    platforms:
      windows:
        pluginClass: FbfunctionsPlugin

这是我尝试在 ios 模拟器上运行时遇到的错误:

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running pod install...                                              2.5s
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

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

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
    -> Fetching podspec for `cloud_firestore_web` from `.symlinks/plugins/cloud_firestore_web/ios`
    -> Fetching podspec for `cloud_functions` from `.symlinks/plugins/cloud_functions/ios`
    -> Fetching podspec for `cloud_functions_web` from `.symlinks/plugins/cloud_functions_web/ios`
    -> Fetching podspec for `fbfunctions` from `.symlinks/plugins/fbfunctions/ios`
    [!] No podspec found for `fbfunctions` in `.symlinks/plugins/fbfunctions/ios`

    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/external_sources/path_source.rb:11:in `fetch'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:980:in `fetch_external_source'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:959:in `block (2 levels) in fetch_external_sources'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:958:in `each'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:958:in `block in fetch_external_sources'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:957:in `fetch_external_sources'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer/analyzer.rb:117:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:410:in `analyze'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:235:in `block in resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:234:in `resolve_dependencies'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/installer.rb:156:in `install!'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command/install.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:52:in `run'
    /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.1/bin/pod:55:in `<top (required)>'
    /usr/local/bin/pod:23:in `load'
    /usr/local/bin/pod:23:in `<main>'

Error output from CocoaPods:
↳

    [!] Automatically assigning platform `iOS` with version `10.1` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install
Error launching application on iPhone 11 Pro Max.

如何防止 Flutter 尝试将插件包含在 ios 构建中?

【问题讨论】:

    标签: ios iphone flutter


    【解决方案1】:

    你不能;目前Flutter expects every plugin to have an iOS podspec。在解决此问题之前,解决方法是包含一个虚拟 ios/your_plugin_name.podspec,如您在 federated flutter/plugins plugins 中所见。

    除了 podspec 之外,您不需要文件夹中的任何内容,一旦问题得到解决,您就可以将其删除。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-30
      • 2022-08-16
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多