Skip to content

Commit

Permalink
Fixed symbol collision errors with other plugins by adding RNFS prefi…
Browse files Browse the repository at this point in the history
…x to Download & Upload classes

The Uploader & Downloader classes cause linker errors with other plugins that also implement classes that are called Uploader or Downloader. E.g. this happens when using react-native-fs in combination with Firebase Crash reporting.
Basically both plugins are at fault for not implementing unique class names. This commit adds the RNFS prefix for these classes.
  • Loading branch information
IjzerenHein committed Jul 21, 2016
1 parent b3cef00 commit b26fb5f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Downloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ typedef void (^ErrorCallback)(NSError*);
typedef void (^BeginCallback)(NSNumber*, NSNumber*, NSDictionary*);
typedef void (^ProgressCallback)(NSNumber*, NSNumber*);

@interface DownloadParams : NSObject
@interface RNFSDownloadParams : NSObject

@property (copy) NSString* fromUrl;
@property (copy) NSString* toFile;
Expand All @@ -20,9 +20,9 @@ typedef void (^ProgressCallback)(NSNumber*, NSNumber*);

@end

@interface Downloader : NSObject <NSURLSessionDelegate, NSURLSessionDownloadDelegate>
@interface RNFSDownloader : NSObject <NSURLSessionDelegate, NSURLSessionDownloadDelegate>

- (void)downloadFile:(DownloadParams*)params;
- (void)downloadFile:(RNFSDownloadParams*)params;
- (void)stopDownload;

@end
10 changes: 5 additions & 5 deletions Downloader.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#import "Downloader.h"

@implementation DownloadParams
@implementation RNFSDownloadParams

@end

@interface Downloader()
@interface RNFSDownloader()

@property (copy) DownloadParams* params;
@property (copy) RNFSDownloadParams* params;

@property (retain) NSURLSession* session;
@property (retain) NSURLSessionTask* task;
Expand All @@ -19,9 +19,9 @@ @interface Downloader()

@end

@implementation Downloader
@implementation RNFSDownloader

- (void)downloadFile:(DownloadParams*)params
- (void)downloadFile:(RNFSDownloadParams*)params
{
_params = params;

Expand Down
12 changes: 6 additions & 6 deletions RNFSManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ - (dispatch_queue_t)methodQueue
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
DownloadParams* params = [DownloadParams alloc];
RNFSDownloadParams* params = [RNFSDownloadParams alloc];

NSNumber* jobId = options[@"jobId"];
params.fromUrl = options[@"fromUrl"];
Expand Down Expand Up @@ -280,7 +280,7 @@ - (dispatch_queue_t)methodQueue

if (!self.downloaders) self.downloaders = [[NSMutableDictionary alloc] init];

Downloader* downloader = [Downloader alloc];
RNFSDownloader* downloader = [RNFSDownloader alloc];

[downloader downloadFile:params];

Expand All @@ -289,7 +289,7 @@ - (dispatch_queue_t)methodQueue

RCT_EXPORT_METHOD(stopDownload:(nonnull NSNumber *)jobId)
{
Downloader* downloader = [self.downloaders objectForKey:[jobId stringValue]];
RNFSDownloader* downloader = [self.downloaders objectForKey:[jobId stringValue]];

if (downloader != nil) {
[downloader stopDownload];
Expand All @@ -300,7 +300,7 @@ - (dispatch_queue_t)methodQueue
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
UploadParams* params = [UploadParams alloc];
RNFSUploadParams* params = [RNFSUploadParams alloc];

NSNumber* jobId = options[@"jobId"];
params.toUrl = options[@"toUrl"];
Expand Down Expand Up @@ -342,7 +342,7 @@ - (dispatch_queue_t)methodQueue

if (!self.uploaders) self.uploaders = [[NSMutableDictionary alloc] init];

Uploader* uploader = [Uploader alloc];
RNFSUploader* uploader = [RNFSUploader alloc];

[uploader uploadFiles:params];

Expand All @@ -351,7 +351,7 @@ - (dispatch_queue_t)methodQueue

RCT_EXPORT_METHOD(stopUpload:(nonnull NSNumber *)jobId)
{
Uploader* uploader = [self.uploaders objectForKey:[jobId stringValue]];
RNFSUploader* uploader = [self.uploaders objectForKey:[jobId stringValue]];

if (uploader != nil) {
[uploader stopUpload];
Expand Down
6 changes: 3 additions & 3 deletions Uploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ typedef void (^UploadErrorCallback)(NSError*);
typedef void (^UploadBeginCallback)();
typedef void (^UploadProgressCallback)(NSNumber*, NSNumber*);

@interface UploadParams : NSObject
@interface RNFSUploadParams : NSObject

@property (copy) NSString* toUrl;
@property (copy) NSArray* files;
Expand All @@ -20,9 +20,9 @@ typedef void (^UploadProgressCallback)(NSNumber*, NSNumber*);

@end

@interface Uploader : NSObject <NSURLConnectionDelegate>
@interface RNFSUploader : NSObject <NSURLConnectionDelegate>

- (void)uploadFiles:(UploadParams*)params;
- (void)uploadFiles:(RNFSUploadParams*)params;
- (void)stopUpload;

@end
10 changes: 5 additions & 5 deletions Uploader.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#import "Uploader.h"

@implementation UploadParams
@implementation RNFSUploadParams

@end

@interface Uploader()
@interface RNFSUploader()

@property (copy) UploadParams* params;
@property (copy) RNFSUploadParams* params;

@property (retain) NSURLSessionDataTask* task;

@end

@implementation Uploader
@implementation RNFSUploader

- (void)uploadFiles:(UploadParams*)params
- (void)uploadFiles:(RNFSUploadParams*)params
{
_params = params;

Expand Down

0 comments on commit b26fb5f

Please sign in to comment.