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 23, 2024
1 parent 39762ec commit 5bf695c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 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: "10.15" }
s.source = { :git => "https://github.com/birdofpreyru/react-native-fs.git", :tag => "#{s.version}" }

s.resource_bundles = { 'RNFS_PrivacyInfo' => 'ios/PrivacyInfo.xcprivacy' }
Expand Down
15 changes: 13 additions & 2 deletions 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 Expand Up @@ -141,7 +146,13 @@ namespace JS {
}
@end

@interface ReactNativeFs : RCTEventEmitter <RCTBridgeModule,UIDocumentPickerDelegate>
@interface ReactNativeFs : RCTEventEmitter <
RCTBridgeModule
#if !TARGET_OS_OSX
,UIDocumentPickerDelegate
#endif
>

#endif

@property (retain) NSMutableDictionary* downloaders;
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 5bf695c

Please sign in to comment.