Fix: Sandbox: rsync.samba deny(1) file-write-create (Xcode & Flutter)

Written by

in

Quick answer: This error occurs when Xcode’s User Script Sandboxing blocks build scripts like rsync from writing to undeclared paths. To fix it, open your project’s Build Settings in Xcode, search for ENABLE_USER_SCRIPT_SANDBOXING (User Script Sandboxing), and set it to No. For CocoaPods or Flutter projects, you can also set this flag inside your Podfile’s post_install hook or update your build scripts.

Why this happens

When you see Sandbox: rsync.samba(...) deny(1) file-write-create in Xcode, macOS is blocking a Run Script build phase from creating or modifying files during compilation. This commonly appears when building Flutter apps for iOS, projects using CocoaPods, or custom shell scripts that invoke rsync to copy frameworks and assets into your app bundle.

The root cause is Xcode’s User Script Sandboxing feature (ENABLE_USER_SCRIPT_SANDBOXING). When enabled, Xcode runs custom build scripts inside a strict macOS sandbox that denies read and write access to any file or directory not explicitly listed in the script’s Input Files and Output Files.

If a third-party tool like CocoaPods or a Flutter build script copies files dynamically without declaring every destination path upfront, the sandbox intercepts rsync.samba and aborts the build. Downgrading macOS is not necessary—the restriction is controlled by your Xcode project’s build settings.

How to fix it

1. Disable User Script Sandboxing in Xcode Build Settings

The fastest way to resolve the error is to turn off ENABLE_USER_SCRIPT_SANDBOXING for your app target and project.

  1. Open your project or workspace in Xcode (for Flutter, open ios/Runner.xcworkspace, not Runner.xcodeproj).
  2. In the Project Navigator on the left, select your top-level project (such as Runner).
  3. Select your Project (and repeat for your main Target if it overrides the setting), then open the Build Settings tab.
  4. Make sure All is selected at the top of the Build Settings pane so hidden or default settings appear.
  5. In the top-right search bar of Build Settings, type ENABLE_USER_SCRIPT_SANDBOXING or User Script Sandboxing.
  6. Locate User Script Sandboxing under the Build Options section and change its value from Yes to No.
  7. Clean the build folder with Product > Clean Build Folder (Shift + Command + K) and rebuild your app.

If you have trouble finding the setting in a large workspace, you can also use Xcode’s global Find navigator (Command + 3), make sure the search scope covers your workspace, and search for ENABLE_USER_SCRIPT_SANDBOXING.

2. Apply the setting automatically in your Podfile

If your project uses CocoaPods, running pod install or updating dependencies can sometimes re-introduce sandboxing on pod targets. You can enforce ENABLE_USER_SCRIPT_SANDBOXING = 'NO' across all pod targets by adding a rule to your ios/Podfile inside the post_install block:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
    end
  end
end

If you already have a post_install block in your Podfile (which Flutter projects include by default), add the config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO' line inside the existing target.build_configurations.each loop rather than creating a second post_install block.

After saving the Podfile, run:

cd ios
pod install

Then return to your project root or Xcode and rebuild.

3. Keep sandboxing enabled by declaring script inputs and outputs

If you prefer to keep User Script Sandboxing enabled for better build determinism and security, you need to tell Xcode which files your Run Script phases touch.

  1. Open your target in Xcode and go to the Build Phases tab.
  2. Expand the Run Script phase that triggers rsync (for example, [CP] Embed Pods Frameworks or a custom copy script).
  3. Under Input Files and Output Files (or Input File Lists and Output File Lists), add the exact paths or .xcfilelist references that the script reads from and writes to.
  4. Uncheck Based on dependency analysis only if the script must run on every build, though keeping it checked with accurate file lists is preferred.

For projects managed by CocoaPods or Flutter, manually editing [CP] phases is temporary because pod install regenerates them. In that case, updating your tools is the cleaner path.

4. Update Flutter and CocoaPods

Newer releases of Flutter and CocoaPods include updated build scripts and .xcfilelist definitions designed to work with Xcode’s User Script Sandboxing.

  1. Update Flutter:
flutter upgrade
  1. Update CocoaPods and refresh your pods:
cd ios
pod repo update
pod install
  1. Run flutter clean from your project root and rebuild for iOS.

How to prevent it

  • Open the .xcworkspace file, not .xcodeproj: When using CocoaPods or Flutter, always build from Runner.xcworkspace so CocoaPods scripts and file lists are loaded properly.
  • Version-control your Podfile and project.pbxproj: Keeping ENABLE_USER_SCRIPT_SANDBOXING = NO committed in your repository prevents teammates or CI/CD runners from hitting the same sandbox error on fresh checkouts.
  • Keep CocoaPods and Flutter up to date: Tooling updates regularly add proper input/output file lists for new Xcode security defaults.
  • Declare inputs and outputs on custom scripts: Whenever you write a new Run Script build phase in Xcode, list its input and output paths from the start so it works with sandboxing enabled.

FAQ

Will downgrading macOS fix Sandbox: rsync.samba deny(1) file-write-create?

No, downgrading macOS is unnecessary and generally not recommended. The error is triggered by Xcode’s ENABLE_USER_SCRIPT_SANDBOXING build setting, which you can disable directly in your project’s Build Settings.

Is it safe to set ENABLE_USER_SCRIPT_SANDBOXING to No?

Yes, for most projects—especially Flutter and CocoaPods apps—disabling User Script Sandboxing simply restores Xcode’s previous build script behavior. It only affects build-time shell scripts on your Mac and has no impact on your app’s runtime security or App Store review.

Why does this error happen in VS Code when building a Flutter iOS app?

When you run or build an iOS app from VS Code, Flutter invokes xcodebuild under the hood using your ios/Runner.xcworkspace settings. Disabling ENABLE_USER_SCRIPT_SANDBOXING in Xcode or in ios/Podfile fixes the build in both Xcode and VS Code.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.