Home > Enterprise >  Unity iOS build in Xcode cannot write downloaded images from Firebase Storage
Unity iOS build in Xcode cannot write downloaded images from Firebase Storage

Time:12-26

In the Unity Editor, the app works well with the Firebase storage. Images are downloaded and used. When we build the Unity app for iOS, it gave errors when it tries to download the images from the Firebase Storage. I think, this is an issue to writing permission, and I have no clue on how to solve it from Unity code

What was done

Code

string savePath = Application.persistentDataPath   "/"   data.banner;
            
StorageReference storageRef = storage.GetReference(data.banner);
Task task = storageRef.GetFileAsync(savePath, new StorageProgress<DownloadState>((DownloadState state) => {
    GetComponent<DatabaseManager>().UpdateProgress(state.BytesTransferred, state);
}), CancellationToken.None);

task.ContinueWithOnMainThread(resultTask => {
    if (!resultTask.IsFaulted && !resultTask.IsCanceled && resultTask.IsCompleted) {
        floorCounter  ;

        if (floorCounter == floors.Count) {
            isFloorComplete = true;
        }
    } else {
        Debug.Log(resultTask.Exception.ToString());

        errorCaught = true;
        return;
    }
});

Errors

System.AggregateException: One or more errors occurred. ---> Firebase.Storage.StorageException: An unknown error occurred
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.Storage.StorageException: An unknown error occurred<---

<>c__DisplayClass3_1:<DownloadImages>b__3(Task)
System.Action`1:Invoke(T)
Firebase.Extensions.<ContinueWithOnMainThread>c__AnonStorey1:<>m__0()
System.Func`1:Invoke()
Firebase.<RunAsync>c__AnonStorey1`1:<>m__0()
System.Action:Invoke()
Firebase.ExceptionAggregator:Wrap(Action)
Firebase.Dispatcher:PollJobs()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

The errors is not helpful and to make it worse, I don't know how to find the debug log mentioned at Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35). I've opened the Xcode project, and see no Runtime folder (even after showing hidden items)

Any idea how to solve this issue?

CodePudding user response:

The solution was certainly not obvious.

Apparently, all I need to do was to prepend file:/// to the savePath variable, like so:

string savePath = "file:///"   Application.persistentDataPath   "/"   data.banner
  • Related