File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,15 @@ npm install react-native-file-access
13
13
cd ios && pod install
14
14
```
15
15
16
+ Apple restricts usage of certain privacy sensitive API calls. If you do not
17
+ use disk space measurements or file timestamps, define the following variable
18
+ in your Podfile to exclude restricted API calls.
19
+ [ More details.] ( https://github.com/alpha0010/react-native-file-access/issues/73 )
20
+
21
+ ``` ruby
22
+ $RNFANoPrivacyAPI = true
23
+ ```
24
+
16
25
If the app does not use autolinking, continue to the [ manual install instructions] ( https://github.com/alpha0010/react-native-file-access/wiki/Manual-Installation ) in the wiki.
17
26
18
27
### Compatibility
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ Pod::Spec.new do |s|
19
19
s . dependency "React-Core"
20
20
s . dependency "ZIPFoundation" , "0.9.11"
21
21
22
+ if defined? ( $RNFANoPrivacyAPI)
23
+ Pod ::UI . puts "#{ s . name } : Removing privacy sensitive API calls"
24
+ s . pod_target_xcconfig = {
25
+ "OTHER_SWIFT_FLAGS" => "-DNO_PRIVACY_API"
26
+ }
27
+ end
28
+
22
29
# Don't install the dependencies when we run `pod install` in the old architecture.
23
30
if ENV [ 'RCT_NEW_ARCH_ENABLED' ] == '1' then
24
31
s . compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
Original file line number Diff line number Diff line change @@ -126,6 +126,9 @@ public class FileAccess : NSObject {
126
126
@objc ( df: withRejecter: )
127
127
public func df( resolve: @escaping RCTPromiseResolveBlock , reject: @escaping RCTPromiseRejectBlock ) -> Void {
128
128
DispatchQueue . global ( ) . async {
129
+ #if NO_PRIVACY_API
130
+ reject ( " ERR " , " Filesystem stat API disabled via compile time flag. " , nil )
131
+ #else
129
132
do {
130
133
let stat = try FileManager . default. attributesOfFileSystem (
131
134
forPath: NSSearchPathForDirectoriesInDomains ( . documentDirectory, . userDomainMask, true ) . first!
@@ -138,6 +141,7 @@ public class FileAccess : NSObject {
138
141
} catch {
139
142
reject ( " ERR " , " Failed to stat filesystem. \( error. localizedDescription) " , error)
140
143
}
144
+ #endif
141
145
}
142
146
}
143
147
@@ -350,9 +354,14 @@ public class FileAccess : NSObject {
350
354
private func statFile( path: String ) throws -> [ String : Any ? ] {
351
355
let pathUrl = URL ( fileURLWithPath: path. path ( ) )
352
356
let attrs = try FileManager . default. attributesOfItem ( atPath: path. path ( ) )
357
+ #if NO_PRIVACY_API
358
+ let lastModified = 0
359
+ #else
360
+ let lastModified = 1000 * ( attrs [ . modificationDate] as! NSDate ) . timeIntervalSince1970
361
+ #endif
353
362
return [
354
363
" filename " : pathUrl. lastPathComponent,
355
- " lastModified " : 1000 * ( attrs [ . modificationDate ] as! NSDate ) . timeIntervalSince1970 ,
364
+ " lastModified " : lastModified ,
356
365
" path " : pathUrl. path,
357
366
" size " : attrs [ . size] ,
358
367
" type " : self . checkIfIsDirectory ( path: path) . isDirectory ? " directory " : " file "
You can’t perform that action at this time.
0 commit comments