美文网首页
Mac Flutter配置

Mac Flutter配置

作者: 云醉倚清风 | 来源:发表于2019-07-31 17:39 被阅读0次

    Flutter中文网
    \color{#FF1212}{注意:目前看来需要使用科学上网才能进入下载页面,当前版本1.20.4,2020/09/19}

    一:Flutter环境配置

    1:Flutter SDK下载
    这里我下载的是flutter_macos_v1.7.8+hotfix.4-stable解压到盘目录/Users/yaodong/flutter
    2:环境配置
    首先查看自己所使用的shell https://support.apple.com/zh-cn/HT208050
    如果是 bash

    环境变量配置:
    vim ~/.bash_profile 
    添加环境变量:
    export PATH="/Users/yaodong/flutter/bin:$PATH"
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_UUL=https://storage.flutter-io.cn
    保存后刷新:
    source ~/.bash_profile
    

    如果是 zsh

    环境变量配置:
    vim .zshrc 
    添加环境变量:
    export PATH="/Users/yaodong/flutter/bin:$PATH"
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_UUL=https://storage.flutter-io.cn
    保存后刷新:
    source .zshrc  
    

    注意:终端编辑命令i编辑,esc输入命令,:wq保存并退出
    3:运行 flutter doctor
    打开 终端,输入flutter doctor

    • 出现:Android证书问题
    //出现  Android证书问题
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor -- android-licenses
    //执行
    flutter doctor --android-licenses   一直Yes即可
    
    • 出现:Xcode 环境设备验证问题
    // 出现Xcode 环境设备验证
    // mac os 10.15版本 软件安装目录有问题,务必更新到brew最新版本2.1.9
    Verify that all connected devices have been paired with this computer in Xcode.
    // 按提示依次执行
    To update with Brew, run:
            brew update
            brew uninstall --ignore-dependencies libimobiledevice
            brew uninstall --ignore-dependencies usbmuxd
            brew install --HEAD usbmuxd
            brew unlink usbmuxd
            brew link usbmuxd
            brew install --HEAD libimobiledevice
            brew install ideviceinstaller
    
    • 出现 ios-deploy 未安装
    //这个是终端安装和调试iPhone应用的是第三方开源库
    [!] iOS tools - develop for iOS devices
        ✗ ios-deploy out of date (1.9.4 is required). To upgrade with Brew:
            brew upgrade ios-deploy
    // 我这里使用node安装的
    
    • 出现:开发环境配置问题(下面会讲到)
    // 出现   开发环境配置问题,下面会讲到
    [!]Android Studio (version 3.4)  
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
     //如果安装了 IntelliJ IDEA 也会检测到
    [!] IntelliJ IDEA Ultimate Edition (version 2017.2.5)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    
    • ios-deploy not installed 按照提示执行brew install ios-deploy
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    [!] iOS tools - develop for iOS devices
        ✗ ios-deploy not installed. To install:
            brew install ios-deploy
    [✓] Android Studio (version 3.4)
    [!] IntelliJ IDEA Ultimate Edition (version 2017.2.5)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [!] Connected device
        ! No devices available
    

    二:Flutter IDE 配置

    1:Android Studio或Viual Studio Code下载
    2:Android Studio 在File>Setting>Plugins>MarketPlace中搜索Flutter,安装搜索结果第一条,成功后按提示重启
    3:Android Studio File>Setting>Languages>Flutter中设置Flutter路径,/Users/yaodong/flutter
    4: Android Studio File>Setting>Languages>Dart 中设置Dart SDK,/Users/yaodong/flutter/bin/cache/dart-sdk(第一步已直接设置好,检查即可)

    三:最终运行flutter doctor

    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    [✓] iOS tools - develop for iOS devices
    [✓] Android Studio (version 3.4)
    [!] IntelliJ IDEA Ultimate Edition (version 2017.2.5)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [!] Connected device
        ! No devices available
    

    1:因为我安装了IntelliJ IDEA,所以提示我需要配置flutter环境变量
    2:未连接真机或者未生成模拟器,会提示No devices available

    四:工程运行

    1:File>New>New Flutter Project
    2:运行(连接真机或新建模拟器即可)

    Launching lib/main.dart on YDPhone in debug mode...
    Signing iOS app for device deployment using developer identity: "iPhone Developer: xxxxx"
    Running Xcode build...
    Xcode build done.                                           17.0s
    Installing and launching...
    Syncing files to device YDPhone...
    

    相关文章

      网友评论

          本文标题:Mac Flutter配置

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