无法构建iOS应用(Xcode版本9.4.1(9F2000),Flutter 0.5.1)

时间:2018-07-06 02:47:38

标签: xcode dart flutter

这是一个试驾示例“ https://flutter.io/get-started/test-drive/#terminal” 我遇到以下错误,请评论如何解决此问题。

Xcode's output:
↳
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    clang-3.5: error: unknown argument: '-gmodules'
    clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
    clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
    clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
    Command /usr/local/bin/clang-omp failed with exit code 1
    clang-3.5: error: unknown argument: '-gmodules'
    clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
    clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
    clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
    Command /usr/local/bin/clang-omp failed with exit code 1
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    error: the following command failed with exit code 1 but produced no further output
    CompileC /Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner_vers.o /Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/DerivedSources/Runner_vers.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
    clang-3.5: error: unknown argument: '-gmodules'
    clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
    clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
    clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
    Command /usr/local/bin/clang-omp failed with exit code 1
    clang-3.5: error: unknown argument: '-gmodules'
    clang-3.5: error: unknown argument: '-fbuild-session-file=/Users/nelson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
    clang-3.5: error: no such file or directory: '/Users/nelson/Library/Developer/Xcode/DerivedData/Runner-ctvpprsqskddfxbtqtsepwpaebqm/Index/DataStore'
    clang-3.5: error: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
    Command /usr/local/bin/clang-omp failed with exit code 1
Could not build the application for the simulator.
Error launching application on iPhone 7 Plus.

1 个答案:

答案 0 :(得分:0)

我已经解决了以下问题:

如果仔细查看问题,它触发了clang 3.5的过时版本,我卸载了过时版本并安装了新版本。

  1. 从os x删除clang-omp

    $ brew uninstall clang-omp
    
  2. 卸载clang-omp后,需要flutter安装程序才能更新到最新版本。实际上,我之前做了更新,但是我又做了一次。

    $ flutter upgrade
    
  3. 我尝试再次运行flutter,但无法编译。它不见了cl​​ang-omp

    $ flutter run    
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
        error: can't exec '/usr/local/bin/clang-omp' (No such file or directory)
        Command /usr/local/bin/clang-omp failed with exit code 71
        error: can't exec '/usr/local/bin/clang-omp' (No such file or directory)
        Command /usr/local/bin/clang-omp failed with exit code 71
    
  4. 因为在编译过程中需要更新的clang版本。我安装了llvm

    $ brew install llvm
    
  5. 并相应地更新PATH。

    echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
    
  6. 再次编译应用程序,它已成功编译。

    $ flutter run
    Launching lib/main.dart on iPhone 7 Plus in debug mode...
    Starting Xcode build...                                          
    ├─Assembling Flutter resources...                    1.1s
    └─Compiling, linking and signing...                  8.6s
    Xcode build done.                                           11.3s
    Syncing files to device iPhone 7 Plus...                     3.9s
    
      To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
    An Observatory debugger and profiler on iPhone 7 Plus is available at: http://127.0.0.1:8100/
    For a more detailed help message, press "h". To quit, press "q".
    
    Initializing hot reload...                                       
    Reloaded 0 of 391 libraries in 486ms.