首页 > 解决方案 > 无法为 iOS 构建应用程序,“无法写入模块会话文件 Session.modulevalidation 没有这样的文件或目录”

问题描述

昨天我在 Flutter 上工作得很好,现在我正面临这个问题,我已经到处寻找解决方案,但没有成功。

当我运行时:

flutter run

构建过程开始,当它即将完成时,显示以下错误:

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Xcode build done.                                           12.3s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    error: unable to write module session file at '/Users/hencke/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation': fopen(/Users/hencke/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation, wb): No such file or directory (2)
    note: Using new build system
    note: Planning build
    note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
Exited (sigterm)

看起来该进程正在尝试打开此文件Session.modulevalidation进行写入,但该文件夹中确实不存在此文件。而且我不知道该怎么办。

我已经尝试过的事情:

  1. 重新安装 xcode
  2. 扑干净
  3. 在另一个文件夹中再次克隆我的项目并尝试构建,但同样的错误
  4. 创建了一个新的颤振虚拟项目并尝试构建,仍然是同样的错误
  5. 多次重启机器
  6. 授予员工对DerivedDataModuleCache.noindex文件夹的权限
  7. 删除了DerivedData希望 xcode build 将重新创建所需的所有文件,但是,它再次创建了所有内容,但没有创建该特定文件。

就是这样,如果任何有福的人知道如何“重新创建”,或重置,清除一些缓存,我将非常感激。

标签: iosxcodeflutterbuild

解决方案


在运行项目之前,请检查运行时是否检查了所有内容:

flutter doctor

并确保至少连接了一个设备或首先打开 iOS 模拟器。您可以通过以下方式检查flutter是否成功连接到设备:

flutter devices

当您确保颤振检测到您的设备或模拟器时,然后通过以下方式运行您的应用程序:

flutter run

推荐阅读