Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add react-native-macos support #69

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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