最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Flutter build for macOS fails with an error - Stack Overflow

programmeradmin0浏览0评论

I was trying to build a flutter project for macOS. I have updated pod and then also ran flutter clean. After that I ran flutter run -d macOS and it stills gives the following error:

ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
error: Sandbox: rsync.samba(24941) deny(1) file-write-create /Users//work/project/build/macos/Build/Products/Debug/FlutterMacOS.framework (in target 'Flutter Assemble' from project 'Runner')
error: Sandbox: dart(24910) deny(1) file-read-data /Users//work/project/build/macos/Build/Products/Debug (in target 'Flutter Assemble' from project 'Runner')
error: Sandbox: dart(24910) deny(1) file-write-create /Users//work/project/build/macos/Build/Products/Debug/.last_build_id (in target 'Flutter Assemble' from project 'Runner')
Flutter failed to write to a file at "/Users//work/project/build/macos/Build/Products/Debug/.last_build_id".
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami) /Users//work/project/build/macos/Build/Products/Debug/.last_build_id

warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'BoringSSL-GRPC' from project 'Pods')
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'abseil' from project 'Pods')
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-Core' from project 'Pods')
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-C++' from project 'Pods')
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

Here is the output of flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.1, on macOS 15.3.1 24D70 darwin-arm64, locale
    en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.98.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

I have no idea what is causing the problem. I also don't have much knowledge about compiling flutter for macOS. Is there any important step I am missing?

I was trying to build a flutter project for macOS. I have updated pod and then also ran flutter clean. After that I ran flutter run -d macOS and it stills gives the following error:

ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
ld: warning: ignoring duplicate libraries: '-lc++'
error: Sandbox: rsync.samba(24941) deny(1) file-write-create /Users//work/project/build/macos/Build/Products/Debug/FlutterMacOS.framework (in target 'Flutter Assemble' from project 'Runner')
error: Sandbox: dart(24910) deny(1) file-read-data /Users//work/project/build/macos/Build/Products/Debug (in target 'Flutter Assemble' from project 'Runner')
error: Sandbox: dart(24910) deny(1) file-write-create /Users//work/project/build/macos/Build/Products/Debug/.last_build_id (in target 'Flutter Assemble' from project 'Runner')
Flutter failed to write to a file at "/Users//work/project/build/macos/Build/Products/Debug/.last_build_id".
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami) /Users//work/project/build/macos/Build/Products/Debug/.last_build_id

warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'BoringSSL-GRPC' from project 'Pods')
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'abseil' from project 'Pods')
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-Core' from project 'Pods')
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'gRPC-C++' from project 'Pods')
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

Here is the output of flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.1, on macOS 15.3.1 24D70 darwin-arm64, locale
    en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.98.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

I have no idea what is causing the problem. I also don't have much knowledge about compiling flutter for macOS. Is there any important step I am missing?

Share Improve this question edited Mar 13 at 18:35 Mastermindsap asked Mar 13 at 0:26 MastermindsapMastermindsap 581 silver badge10 bronze badges 2
  • Can you also provide the output for flutter doctor? It seems like flutter is encountering problems with the writing permissions in the projects folder – xaer Commented Mar 13 at 14:09
  • @xaer I have added the flutter doctor output in the question itself. – Mastermindsap Commented Mar 14 at 6:50
Add a comment  | 

1 Answer 1

Reset to default 1

From your terminal, we have the clue of what's going wrong. The erros are:

error: Sandbox: rsync.samba(24941) deny(1) file-write-create /Users//work/project/build/macos/Build/Products/Debug/FlutterMacOS.framework (in target 'Flutter Assemble' from project 'Runner')
error: Sandbox: dart(24910) deny(1) file-read-data /Users//work/project/build/macos/Build/Products/Debug (in target 'Flutter Assemble' from project 'Runner')
error: Sandbox: dart(24910) deny(1) file-write-create /Users//work/project/build/macos/Build/Products/Debug/.last_build_id (in target 'Flutter Assemble' from project 'Runner')

Which means that your system is denying to write-create the file on the paths.
I may try:
sudo chown -R $(whoami):$(whoami) /Users/<your_user_name>/work/project
Note: replace <your_user_name> to your user name on your Mac

Then, just follow the usual steps for fluter clean & flutter run -d macos

If it doesn't work, I would understand why your system is denying to write-create. Because doctor is returning that there isn't error for macos.

发布评论

评论列表(0)

  1. 暂无评论