美文网首页
Flutter 2.x使用webview_flutter遇到un

Flutter 2.x使用webview_flutter遇到un

作者: 前端技术小咖 | 来源:发表于2021-03-13 23:45 被阅读0次

    Flutter终于推出2.0版本了,兴奋升级尝鲜后发现编译的时候webview_flutter报错:undefined method `each_child' for #<Dir:0x007fb3fb295160>
    关键日志信息如下:

    Running pod install...
    CocoaPods' output:
    ↳
          Preparing
    
        Analyzing dependencies
    
        Inspecting targets to integrate
          Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    
        ......
    
        Comparing resolved specification to the sandbox manifest
          - Flutter
          - webview_flutter
    
        Downloading dependencies
    
        -> Using Flutter (1.0.0)
    
        ......
          - Generating deterministic UUIDs
          - Stabilizing target UUIDs
          - Running post install hooks
        [!] An error occurred while processing the post-install hook of the Podfile.
    
        undefined method `each_child' for #<Dir:0x007fb3fb295160>
        Did you mean?  each_slice
    
        /Users/shuaitao/Library/flutter/packages/flutter_tools/bin/podhelper.rb:54:in `block in flutter_additional_ios_build_settings'
        /Users/shuaitao/Library/flutter/packages/flutter_tools/bin/podhelper.rb:51:in `each'
        /Users/shuaitao/Library/flutter/packages/flutter_tools/bin/podhelper.rb:51:in `flutter_additional_ios_build_settings'
        /Users/shuaitao/Project/moxie/ios/Podfile:39:in `block (3 levels) in from_ruby'
        /Users/shuaitao/Project/moxie/ios/Podfile:38:in `each'
        /Users/shuaitao/Project/moxie/ios/Podfile:38:in `block (2 levels) in from_ruby'
        /Users/shuaitao/.rvm/gems/ruby-2.4.1/gems/cocoapods-core-1.10.1/lib/cocoapods-core/podfile.rb:179:in `post_install!'
       ......
    
    Error output from CocoaPods:
    ↳
    
        [!] Automatically assigning platform `iOS` with version `9.0` 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 12 Pro Max.
    
    

    经过调查发现,Dir.each_child方法是ruby 2.5版本才支持,使用ruby -v看到本地安装的是ruby 2.4.1版本。知道问题原因后,接下来的解决方案是使用rvm install 2.5.1升级ruby的版本:

    rvm install 2.5.1
    

    如果升级的过程中有可能会遇到No fallback URL could be found错误, 详细错误日志如下:

    Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
    No fallback URL could be found, try increasing timeout with:
    
        echo "export rvm_max_time_flag=20" >> ~/.rvmrc
    
    There has been an error fetching the ruby interpreter. Halting the installation.
    

    根据具体执行echo "export rvm_max_time_flag=20" >> ~/.rvmrc指令,并再次执行ruby升级命令即可:

    echo "export rvm_max_time_flag=20" >> ~/.rvmrc
    rvm install 2.5.1
    

    最后,ruby升级完成后需要彻底删除 webview_flutter组件,重启IDE后,再次集成 webview_flutter组件即可。

    相关文章

      网友评论

          本文标题:Flutter 2.x使用webview_flutter遇到un

          本文链接:https://www.haomeiwen.com/subject/kdvxcltx.html