From 0ff7b88ce481b4e8f081e925f5c8b0dd9f09eb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hampus=20Sj=C3=B6berg?= Date: Tue, 10 Sep 2024 01:23:03 +0200 Subject: [PATCH] Add react-native-macos support --- dr-pogodin-react-native-fs.podspec | 2 +- ios/ReactNativeFs.h | 7 ++++++- ios/ReactNativeFs.mm | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dr-pogodin-react-native-fs.podspec b/dr-pogodin-react-native-fs.podspec index a1203783..caa794c5 100644 --- a/dr-pogodin-react-native-fs.podspec +++ b/dr-pogodin-react-native-fs.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.license = package["license"] s.authors = package["author"] - s.platforms = { :ios => min_ios_version_supported } + s.platforms = { :ios => min_ios_version_supported, osx: min_macos_version_supported } s.source = { :git => "https://github.com/birdofpreyru/react-native-fs.git", :tag => "#{s.version}" } s.resource_bundles = { 'RNFS_PrivacyInfo' => 'ios/PrivacyInfo.xcprivacy' } diff --git a/ios/ReactNativeFs.h b/ios/ReactNativeFs.h index 5ad79d81..c98355ee 100644 --- a/ios/ReactNativeFs.h +++ b/ios/ReactNativeFs.h @@ -3,7 +3,12 @@ #ifdef RCT_NEW_ARCH_ENABLED #import "RNReactNativeFsSpec.h" -@interface ReactNativeFs : RCTEventEmitter +@interface ReactNativeFs : RCTEventEmitter < + NativeReactNativeFsSpec +#if !TARGET_OS_OSX + ,UIDocumentPickerDelegate +#endif +> #else #import #import diff --git a/ios/ReactNativeFs.mm b/ios/ReactNativeFs.mm index 09c477dd..94e994c4 100644 --- a/ios/ReactNativeFs.mm +++ b/ios/ReactNativeFs.mm @@ -1129,6 +1129,7 @@ - (void)setReadable:(NSString *)filepath readable:(BOOL)readable ownerOnly:(BOOL [[RNFSException NOT_IMPLEMENTED] reject:reject details:@"setReadable()"]; } +#if !TARGET_OS_OSX - (void)documentPicker:(UIDocumentPickerViewController *)picker didPickDocumentsAtURLs:(NSArray *)urls { @@ -1178,6 +1179,7 @@ - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)picker } // TODO: Should crash here, as it is a fatal error. } +#endif RCT_EXPORT_METHOD( #ifdef RCT_NEW_ARCH_ENABLED @@ -1188,6 +1190,7 @@ - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)picker resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject ) { +# if TARGET_OS_IOS // NOTE: We must copy options into a local variable, so that (especially with // the new, bridgeless architecture) it is correctly detained by the async // block below, not crushing the app. @@ -1250,6 +1253,9 @@ - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)picker [[RNFSException fromException:e] reject:reject]; } }); +# else + [[RNFSException NOT_IMPLEMENTED] reject:reject details:@"pickFile()"]; +# endif } /**