无法在iPhone 15 Pro Max模拟器构建Flutter iOS应用的问题
在iPhone 15 Pro Max模拟器运行Flutter iOS应用时遇到沙箱写入权限错误
运行应用时触发以下错误:
Error (Xcode): Sandbox: rsync.samba(44106) deny(1) file-write-create /Users/mustafa/Desktop/flutter_starter/build/ios/Debug-iphonesimulator/Flutter.framework Error (Xcode): Sandbox: dart(44085) deny(1) file-write-create /Users/mustafa/Desktop/flutter_starter/build/ios/Debug-iphonesimulator/.last_build_id Error (Xcode): Flutter failed to write to a file at "/Users/mustafa/Desktop/flutter_starter/build/ios/Debug-iphonesimulator/.last_build_id".
本地flutter doctor检测无异常:
[✓] Flutter (Channel master, 3.14.0-14.0.pre.362, on macOS 14.0 23A344 darwin-arm64, locale en-TZ) • Flutter version 3.14.0-14.0.pre.362 on channel master at /Users/mustafa/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5b47fef613 (2 weeks ago), 2023-09-19 15:49:57 -0400 • Engine revision 28f14e6eec • Dart version 3.2.0 (build 3.2.0-179.0.dev) • DevTools version 2.28.0-dev.8 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /Users/mustafa/Library/Android/sdk • Platform android-33, build-tools 33.0.1 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A240d • CocoaPods version 1.12.1 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) [✓] VS Code (version 1.82.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.74.0 [✓] Connected device (3 available) • iPhone 15 Pro Max (mobile) • C6431A06-5012-47C7-AFDE-B522E40E339B • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.0 23A344 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 117.0.5938.132 [✓] 网络资源 • 所有预期网络资源均可用。 • 未发现任何问题!
解决方案尝试:
清理构建缓存与依赖
执行以下命令彻底清理后重新构建:flutter clean rm -rf ios/Pods ios/Podfile.lock flutter pub get cd ios && pod install调整Xcode沙箱权限
打开iOS项目的Runner.xcworkspace,进入Target > Runner > Signing & Capabilities:- 若开启了
App Sandbox,检查File Access模块,添加对User Selected File的读写权限; - 调试阶段可暂时关闭
App Sandbox,确认是否为沙箱限制导致问题。
- 若开启了
修复目录权限
手动赋予构建目录足够的读写权限:chmod -R 755 /Users/mustafa/Desktop/flutter_starter/build/ios/Debug-iphonesimulator切换Flutter稳定通道
当前使用master开发通道,可能存在未修复的兼容性问题,切换到稳定版尝试:flutter channel stable flutter upgrade重启相关进程
重启iPhone模拟器、Xcode,必要时重启电脑,排除进程缓存干扰。
内容的提问来源于stack exchange,提问作者Mustafa Ismailjee
相关产品推荐
相关产品推荐

