Xcode build fails with Sandbox: rsync.samba deny(1) file-write-create
Sandbox: rsync.samba (13105) deny(1) file-write-createShort answer
Xcode runs script build phases inside a sandbox, and a pod or framework script that runs rsync is blocked from writing into the app. First read the real value of ENABLE_USER_SCRIPT_SANDBOXING in the build log. If it is YES in any target, including Pods, set it to NO.
Fix it fast
1Find out which cause you have
Make the script phase print its settings. Select the failing Run Script phase in the target's Build Phases, enable Show environment variables in build log, build again, and read the value of ENABLE_USER_SCRIPT_SANDBOXING in the log.
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -showBuildSettings | grep ENABLE_USER_SCRIPT_SANDBOXING2Match what you see, then jump to its fix
What does the error look like?
Sandbox: rsync.samba (13105) deny(1) file-write-createFlutter failed to write to a file
Cause 1 of 2
Script sandboxing is still on in some target
1Check
The value can come from the Runner project, the Runner target or the Pods project, which has its own targets. Setting it in only one place can leave it enabled in another.
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -showBuildSettings | grep ENABLE_USER_SCRIPT_SANDBOXING2Fix
In Xcode, search Build Settings for User Script Sandboxing and set it to No in each place that still shows Yes, including the Pods project, then clean and build.
# Xcode: select the project or target > Build Settings
# search "User Script Sandboxing" > set No (Pods project included)
# then read the value again:
xcodebuild -workspace ios/Runner.xcworkspace -scheme Runner -showBuildSettings | grep ENABLE_USER_SCRIPT_SANDBOXING3Verify
Clean the build folder and rebuild.
flutter clean && flutter build ios --no-codesignConfirmed by developer.apple.com
Cause 2 of 2
It is already NO, but a dependency's script still needs rsync
1Check
An Apple DTS engineer says to look at what the dependency's own script does when the setting is already NO, because it still depends on rsync.
grep -n "rsync" ios/Pods/Target\ Support\ Files/*/*.sh | head2Fix
Ask the vendor of that SDK for its integration requirements. Apple calls the sandbox the default and recommended setting, and suggests an integration that avoids build scripts, such as Swift Package Manager, if the vendor offers it.
# no command: follow the SDK vendor's current integration guide3Verify
Build after updating the dependency to the vendor's current release.
flutter build ios --no-codesignConfirmed by developer.apple.com
How do I stop it coming back?
- Read an SDK vendor's integration notes before adding it, since some need script phases.
- Re-check the setting after every Xcode upgrade.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
Related fixes
Mobile apps
Apple rejected the app under Guideline 4.3, Design: Spam
Guideline 4.3(b) - Design - Spam
Guideline 4.3 is Apple's duplicate rule.
5 causes, each with a fixMobile apps
pod install cannot pick a version of a pod that satisfies every requirement
Specs satisfying the `FirebaseAuth (~> 11.0)` dependency were found, but they required a higher minimum deployment target.
CocoaPods tried every version of the named pod and none fit all requirements.
4 causes, each with a fixMobile apps
flutter run says: Could not run Runner.app, try Xcode Product > Run
Try launching Xcode and selecting "Product > Run" to fix the problem:
Flutter prints this when installing or launching the built app on the iPhone fails, and it hides the real reason.
4 causes, each with a fixMobile apps
flutter doctor says CocoaPods is installed but not working
You appear to have CocoaPods installed but it is not working.
Flutter runs pod --version and treats a failed or unreadable result as a broken install.
3 causes, each with a fixMobile apps
flutter run on iOS or macOS stops with Error running pod install
Warning: CocoaPods not installed. Skipping pod install.
Flutter only reports that pod install failed; the reason is in the lines just above it.
5 causes, each with a fixMobile apps
FirebaseMessaging.getAPNSToken() returns null on iOS
FirebaseMessaging.instance.getAPNSToken() returns null
getAPNSToken() gives null when iOS has not handed the app an APNs token yet or never will.
4 causes, each with a fix