itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.88k stars 952 forks source link

iOS privacy manifest #1232

Open gabrielguilhoto opened 1 month ago

gabrielguilhoto commented 1 month ago

Starting May 1, Apple will require iOS submissions to the App Store to have privacy manifests describing the use of required reason APIs: https://developer.apple.com/news/?id=3d8a9yyh.

I used a script to find required reason APIs in our project and it pointed to 4 uses by react-native-fs in the RNFSManager.m file, at least in version 2.19.0:

Could you please add the required privacy manifest?

gkasireddy202 commented 1 month ago

How to download sh required_reason_api_scanner.sh YourAppDirectory and run in your react-native project?

gabrielguilhoto commented 1 month ago

How to download sh required_reason_api_scanner.sh YourAppDirectory and run in your react-native project?

You can clone the https://github.com/Wooder/ios_17_required_reason_api_scanner repository to be able to run it.

gkasireddy202 commented 1 month ago

@gabrielguilhoto - Thanks for your reply.

gkasireddy202 commented 1 month ago

@gabrielguilhoto - After I cloned the git on my desktop.Getting error. sh required_reason_api_scanner.sh Desktop

sh: required_reason_api_scanner.sh: No such file or directory

WilliamWelsh commented 1 month ago

@gabrielguilhoto - After I cloned the git on my desktop.Getting error. sh required_reason_api_scanner.sh Desktop

sh: required_reason_api_scanner.sh: No such file or directory

If you cloned it on your desktop then there is no folder called Desktop... you would just put ....

gkasireddy202 commented 1 month ago

@WilliamWelsh - Thanks it is working. Is it mandatory to update every library for iOS privacy manifest?

birdofpreyru commented 1 month ago

Yeah... should I mention it once again, #1197 — The future of react-native-fs? You probably should migrate to my fork of the lib, and file new issues, do any contributions in there.

gkasireddy202 commented 1 month ago

I am using react-native-fs:2.20.0. Can I update this library for the iOS privacy manifest file?

stami commented 2 weeks ago

I have no use for disk space APIs so I removed them with patch-package:

diff --git a/node_modules/react-native-fs/RNFSManager.m b/node_modules/react-native-fs/RNFSManager.m
index 5ddd941..80fb3e9 100755
--- a/node_modules/react-native-fs/RNFSManager.m
+++ b/node_modules/react-native-fs/RNFSManager.m
@@ -726,24 +726,11 @@ + (BOOL)requiresMainQueueSetup
 {
   unsigned long long totalSpace = 0;
   unsigned long long totalFreeSpace = 0;
-
-  __autoreleasing NSError *error = nil;
-  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-  NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error:&error];
-
-  if (dictionary) {
-    NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
-    NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
-    totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
-    totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
-
-    resolve(@{
-      @"totalSpace": [NSNumber numberWithUnsignedLongLong:totalSpace],
-      @"freeSpace": [NSNumber numberWithUnsignedLongLong:totalFreeSpace]
-    });
-  } else {
-    [self reject:reject withError:error];
-  }
+  // Remove disk space APIs to not to trigger NSPrivacyAccessedAPICategoryDiskSpace for privacy manifest
+  resolve(@{
+    @"totalSpace": [NSNumber numberWithUnsignedLongLong:totalSpace],
+    @"freeSpace": [NSNumber numberWithUnsignedLongLong:totalFreeSpace]
+  });
 }
MianSaad705 commented 4 days ago

@gabrielguilhoto @gkasireddy202 Have You found any workaround for this or do we have to manually add the reason in PrivacyInfo.xcprivacy under this API Type NSPrivacyAccessedAPICategoryFileTimestamp.

gkasireddy202 commented 4 days ago

Have You found any workaround for this or do we have to manually add the reason in PrivacyInfo.xcprivacy under this API Type NSPrivacyAccessedAPICategoryFileTimestamp.

I added this API reason in PrivacyInfo.xcprivacy file in my app.

MianSaad705 commented 4 days ago

@gkasireddy202 Under this API NSPrivacyAccessedAPICategoryFileTimestamp? Secondly after adding apple approved your app without any warnings? Kindly mention which reason you add

https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api

gkasireddy202 commented 4 days ago

@MianSaad705 - I added the below API type and reason in my app privacy file.I did not get any warning emails from Apple and also app is approved.

NSPrivacyAccessedAPIType NSPrivacyAccessedAPICategoryFileTimestamp NSPrivacyAccessedAPITypeReasons C617.1
MianSaad705 commented 4 days ago

@gkasireddy202 Thanks.