Skip to content

Commit

Permalink
Add react-native-macos support
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Sep 9, 2024
1 parent 39762ec commit 0ff7b88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dr-pogodin-react-native-fs.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
7 changes: 6 additions & 1 deletion ios/ReactNativeFs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNReactNativeFsSpec.h"

@interface ReactNativeFs : RCTEventEmitter <NativeReactNativeFsSpec,UIDocumentPickerDelegate>
@interface ReactNativeFs : RCTEventEmitter <
NativeReactNativeFsSpec
#if !TARGET_OS_OSX
,UIDocumentPickerDelegate
#endif
>
#else
#import <optional>
#import <React/RCTCxxConvert.h>
Expand Down
6 changes: 6 additions & 0 deletions ios/ReactNativeFs.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSURL *> *)urls
{
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -1250,6 +1253,9 @@ - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)picker
[[RNFSException fromException:e] reject:reject];
}
});
# else
[[RNFSException NOT_IMPLEMENTED] reject:reject details:@"pickFile()"];
# endif
}

/**
Expand Down

0 comments on commit 0ff7b88

Please sign in to comment.