Unable to write/read files in documentDirectory in iOS production build

  1. SDK Version: 41
  2. Platforms(Android/iOS/web/all): iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I have an application in which files are downloaded with FileSystem.createDownloadResumable(…).downloadAsync(), and stored in FileSystem.documentsDirectory/files/ (which is created/verified when the app is launched). These files are then viewable in the application.
Everything works fine with Expo Go, but when built for iOS in managed workflow, the app throws this error for each downloaded file :

[Error: Unable to save file to local URI: 'Error Domain=NSCocoaErrorDomain Code=513 "“CFNetworkDownload_hwm9ET.tmp” couldn’t be moved because you don’t have permission to access “files”." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Library/Caches/com.apple.nsurlsessiond/Downloads/*/CFNetworkDownload_hwm9ET.tmp, NSUserStringVariant=(
    Move
), NSDestinationFilePath=/var/mobile/Containers/Data/Application/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/Documents/files/17051.png, NSFilePath=/var/mobile/Library/Caches/com.apple.nsurlsessiond/Downloads/*/CFNetworkDownload_hwm9ET.tmp, NSUnderlyingError=0x283c461c0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}']

This problem happens on an iPad(6th gen) with iOS 15, but not on an iPhone with iOS 12.

A workaround I have for now is to eject Expo, then build the app with Xcode.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.