expo-file-system crash on IOS Simulator

139 Views Asked by At

I have a code that will save a QR generated image (base64) to device folder using expo-file-system

 const saveQrCode = async () => {
    if (QRref) {
      QRref.toDataURL(async (data) => {
        try {
          // Check folder directory
          let file = await FileSystem.getInfoAsync(
            FileSystem.documentDirectory + "QRCode/"
          );

          // Create folder if not exist
          if (!file.exists) {
            await FileSystem.makeDirectoryAsync(
              FileSystem.documentDirectory + "QRCode/",
              { intermediates: true }
            );
          }
          
          const filepath =
            FileSystem.documentDirectory +
            `QRCode/QRCode_${clientName}_${area?.label}_${location?.label}.png`;
          await FileSystem.writeAsStringAsync(filepath, data, {
            encoding: FileSystem.EncodingType.Base64,
          });
          await Sharing.shareAsync(filepath, { mimeType: "image/gif" });
          console.log("success");
        } catch (error) {
          Alert.alert("", error);
        }
      })
    }
};

It work just fine on expo go Android, i can save the file and share it to others as an image but when i tried it on IOS Simulator expo-go will crash and force close without any warning or error displayed on VScode. On their documentation it seems that expo-file-system support ios simulator, im not suree if i missing something regarding to implement it on ios device

my workflow

Expo managed workflow

"expo": "~45.0.0"
"expo-file-system": "~14.0.0",
0

There are 0 best solutions below