Search Unity

how to check free disk space on IOS , please help me .

Discussion in 'Editor & General Support' started by LXL2013, Oct 28, 2013.

  1. LXL2013

    LXL2013

    Joined:
    Sep 26, 2013
    Posts:
    9
    I need to download AssetBundle to my game, so I first need to check how many disk space left on device .
    I just tryed call Caching.spaceFree , but it returns 9223372036854775807 , its very wrong .

    So I tryed to do this by myself . On Android , I implement this by calling AndroidJavaScript.

    But I can't find solution on IOS :confused::confused:, can anyway help me with this ? thx
     
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
  3. LXL2013

    LXL2013

    Joined:
    Sep 26, 2013
    Posts:
    9
  4. musikit

    musikit

    Joined:
    Jan 30, 2012
    Posts:
    160
    native plugin could do it real quick.
     
  5. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
  6. laurelhach

    laurelhach

    Joined:
    Dec 1, 2013
    Posts:
    229
    Lxl2013,

    Did you find a way to make it work? I am also looking for the same thing ...
    Graham, I saw your link, but unfortunately I am not experienced enough to understand how to use the API with NSFileManager.

    I have imported the free version of U3DXT and it seems to be enough to be able to access U3DXT.iOS.Native.Foundation;
    But from there, I have no clue how to convert this : http://stackoverflow.com/questions/...ble-free-disk-space-on-the-iphone-ipad-device into something that works in c#.

    Any help would be appreciated :)

    Thanks.
     
  7. laurelhach

    laurelhach

    Joined:
    Dec 1, 2013
    Posts:
    229
    I don't bump most of the time :) But this is really annoying me :p
    Anyone knows how to convert the script below to make it work in c# ?
    I am using the API from U3DXT.

    Code (csharp):
    1.  
    2. -(uint64_t)getFreeDiskspace {
    3.     uint64_t totalSpace = 0;
    4.     uint64_t totalFreeSpace = 0;
    5.     NSError *error = nil;  
    6.     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
    7.     NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];  
    8.  
    9.     if (dictionary) {  
    10.         NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];  
    11.         NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
    12.         totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
    13.         totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
    14.         NSLog(@"Memory Capacity of %llu MiB with %llu MiB Free memory available.", ((totalSpace/1024ll)/1024ll), ((totalFreeSpace/1024ll)/1024ll));
    15.     } else {  
    16.         NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %@", [error domain], [error code]);  
    17.     }  
    18.  
    19.     return totalFreeSpace;
    20. }
    21.  
    Thanks,
    Laurel.
     
  8. karsnen

    karsnen

    Joined:
    Feb 9, 2014
    Posts:
    65
    NukeboxDev12 and thuandoamanotes like this.
  9. slaga

    slaga

    Joined:
    Dec 3, 2018
    Posts:
    142
    Has anyone made this work in IOS? on Android i have no issues but on IOS i get an undefined symbol error when building on Xcode (Undefined symbol: __iDiskSpace_FreeSpace) as well as during gameplay in the editor (DllNotFoundException: diskUtils)
     
  10. RandomUnityDev123

    RandomUnityDev123

    Joined:
    Oct 28, 2022
    Posts:
    16
    We had this running on Unity 2020.3 on M1 macbooks but as soon as we upgraded to Unity 2021.3 it stopped working with that same DllNotFoundException
     
  11. unmaxim

    unmaxim

    Joined:
    Jul 25, 2013
    Posts:
    6